Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to operate properly #56

Closed
ghost opened this issue Aug 19, 2017 · 2 comments
Closed

Fails to operate properly #56

ghost opened this issue Aug 19, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 19, 2017

Environment

Electron: 1.7.5, Win10 (latest)

Using webpack (if that matters) and TypeScript. Can provide more information if necessary.

Issue

Using the exact copy/paste example given in the readme, I recieve:

Reading C:\dev\PROJECT\dist\manifest.json failed.
Error: ENOENT: no such file or directory, open 'C:\dev\PROJECT\dist\manifest.json'
    at Object.fs.openSync (fs.js:584:18)
    at Object.module.(anonymous function) [as openSync] (ELECTRON_ASAR.js:173:20)
    at Object.fs.readFileSync (fs.js:491:33)
    at Object.fs.readFileSync (ELECTRON_ASAR.js:506:29)
    at getManifestFromPath (C:\dev\PROJECT\node_modules\electron\dist\resources\electron.asar\browser\chrome-extension.js:34:26)
    at Function.BrowserWindow.addDevToolsExtension (C:\dev\PROJECT\node_modules\electron\dist\resources\electron.asar\browser\chrome-extension.js:373:22)
    at App.app.on (C:\dev\PROJECT\dist\main.js:396:19)
    at emitTwo (events.js:111:20)
    at App.emit (events.js:194:7)

However, it SEMI works when executed within app.on('ready', => {})..... {showDevTools: true} doesn't wait for anything and just focuses the active window and operates correctly.

But there is one HUGE caveat.

Since it's executed WITHIN this handler, it never adds the localShortcuts or actually install the devtron extension since the event has already fired.

Suggestion:

Utilize app.isReady() to execute immediately if Ready, and add handler if not... or alter flow of operations.

@ghost
Copy link
Author

ghost commented Aug 19, 2017

OK... After much tinkering, the initial error I posted was due to this module bundling into my webpack output.

However, I think due to my app growing, some initialization timing affects whether the extensions directory is writable, since Electron hasn't fully initialized it's AppData folder. To resolve, I must wait until my own app.on('ready', => {}) executes (as mentioned before).

This is also detailed in Electron's docs regarding BrowserWindow.addDevToolsExtension:

Note: This API cannot be called before the ready event of the app module is emitted.

Furthermore, this module relies too much on timing and requires a BrowserWindow to appear AFTER the module has been called. I am also using electron-devtools-installer and wait until it is finished before calling electron-debug's initializing function. At the same time I've already initialized the rest of the app to speed up response-time during dev.

I have a PR coming soon to fix a lot of these issues, hopefully it satisfies anyone having lifecycle issues.

@ghost ghost mentioned this issue Aug 19, 2017
@sindresorhus
Copy link
Owner

Closing as #57 went stale and I'm now using

await app.whenReady();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant