Service workers fail to load
See original GitHub issue- I have read the contribution documentation for this project.
- I agree to follow the code of conduct that this project follows, as appropriate.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Please describe your issue:
I’m trying to introduce service workers to a project that uses electron-forge, however I ran into an issue where the service worker script fails to load with the following error (in the browser window console):
error when registering service worker TypeError: Failed to register a ServiceWorker: A bad HTTP response code (-1) was received when fetching the script.
Screenshot:
The same code successfully loads the service worker script and registers it when run with electron .
I tried manually installing electron-prebuilt-compile
and using that binary to load my code, and it fails. However, using the electron-prebuilt
binary works. I did try using the .compilerc
at https://github.com/electron/electron-compile#how-can-i-compile-only-some-file-types-but-not-others to stop compiling JS (since I thought it may be an issue caused by transpilation), but still got the same error.
Console output when you run electron-forge
with the environment variable DEBUG=electron-forge:*
. (Instructions on how to do so here). Please include the stack trace if one exists.
Arics-MacBook-Pro:esw aric$ DEBUG=electron-forge:* electron-forge start
WARNING: DEBUG environment variable detected. Progress indicators will be sent over electron-forge:lifecycle
electron-forge:lifecycle Process Started: Checking your system +0ms
electron-forge:lifecycle Process Succeeded: Checking your system +17ms
electron-forge:runtime-config setting key: verbose to value: false +13ms
WARNING: DEBUG environment variable detected. Progress indicators will be sent over electron-forge:lifecycle
electron-forge:lifecycle Process Started: Locating Application +0ms
electron-forge:project-resolver searching for project in: /Users/aric/src/esw +2ms
electron-forge:project-resolver electron-forge compatible package.json found in /Users/aric/src/esw/package.json +6ms
electron-forge:lifecycle Process Succeeded: Locating Application +1ms
electron-forge:lifecycle Process Started: Preparing native dependencies +1ms
electron-forge:lifecycle Process Succeeded: Preparing native dependencies +176ms
electron-forge:hook could not find hook: generateAssets +14ms
electron-forge:lifecycle Process Started: Launching Application +2ms
electron-forge:lifecycle Process Succeeded: Launching Application +7ms
2017-04-26 22:21:57.543 Electron Helper[17241:636606] Couldn't set selectedTextBackgroundColor from default ()
What command line arguments are you passing?
none
What does your config.forge
data in package.json
look like?
"config": {
"forge": {
"make_targets": {
"win32": [
"squirrel"
],
"darwin": [
"zip"
],
"linux": [
"deb",
"rpm"
]
},
"electronPackagerConfig": {},
"electronWinstallerConfig": {
"name": "esw"
},
"electronInstallerDebian": {},
"electronInstallerRedhat": {},
"github_repository": {
"owner": "",
"name": ""
},
"windowsStoreConfig": {
"packageName": "",
"name": "esw"
}
}
}
Please provide either a failing minimal testcase (with a link to the code) or detailed steps to
reproduce your problem. Using electron-forge init
is a good starting point, if that is not the
source of your problem.
I have a repo that demonstrates this issue at https://github.com/concreted/esw, to be run with electron-forge start
. When I run with electron .
it successfully registers the service worker, but with electron-forge start
it fails.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
Never actually tried to use service workers with
electron-compile
, probably need a similar setup to our webview logic.https://github.com/electron-userland/electron-forge/wiki/Using-‘preload’-scripts
Will look into it when I get a change, unless @paulcbetts has any ideas for this 👍
@MarshallOfSound yup after some digging it looks related to the
interceptBufferProtocol
call. @deepak1556 says he sees the issue in electron and will fix there.Going to close this, thanks for your help @MarshallOfSound and @paulcbetts ❤️