Fails to operate properly
opened this issue · comments
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 localShortcut
s 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.
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.