electron / electron/electron

[Feature Request]: Documentation for debugging of preload scripts

Open
#30,470 9 comments 4 reactions 0 assignees View on GitHub
documentation :notebook: enhancement :sparkles:
Dominant language
C++
Stars
123k
Forks
17.5k
Avg merge
14h 22m
Merged PRs (30d)
873

Description

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a feature request that matches the one I want to file, without success.

### Problem Description

Please consider adding an explicit statement to the "[Testing and Debugging](https://www.electronjs.org/docs/latest/)" section of the documentation as to whether it is known and/or expected that a debugger **cannot** be used on **preload** scripts?

Given the security risks of enabling the `nodeIntegration` flag, preload scripts (with context bridging) could become a more commonly used approach to provide a better native application experience.

If `console.log` is the only way to debug preload scripts, that should be stated.

There are many dozens of questions out there asking how to debug preload scripts, but they are all either unanswered, or the response describes how to debug a renderer (as opposed to a preload script).

This [issue #12863](https://github.com/electron/electron/issues/12863) has the most concise and accurate example I've seen of the problem (and incorporates best practice of both node and context isolation). But it was closed without a clear statement of whether this is a defect or a "feature".

### Proposed Solution

I would be happy to provide a PR updating the "[Testing and Debugging](https://www.electronjs.org/docs/latest/)" section of the documentation, if someone on the Electron team could provide official feedback on the question of whether this is even possible.

### Alternatives Considered

N/A

### Additional Information

N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.