gatsby: SecurityError: The operation is insecure in Firefox Developer edition
Description
With gatsby develop and Firefox Developer Edition (latest version, 69.07b), firefox throws a security error exception when app.js
checks if (
serviceWorker in navigator)
, and hence the app cannot be used:
Steps to reproduce
- Install firefox developer edition
- Run gatsby develop on any gatsby project (no offline plugin nor anything sw-related)
Expected result
You see the website and can develop it normally.
Actual result
You get the error above and hence cannot do anything (the error triggers the react overlay error and does not let you interact with the site at all)
Environment
System:
OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 10.16.0 - /tmp/yarn--1564036896798-0.009151794373142508/node
Yarn: 1.17.3 - /tmp/yarn--1564036896798-0.009151794373142508/yarn
npm: 6.9.0 - /usr/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Firefox: 68.0
npmPackages:
gatsby: ^2.1.27 => 2.13.32
gatsby-image: ^2.0.31 => 2.2.6
gatsby-plugin-create-client-paths: ^2.0.4 => 2.1.3
gatsby-plugin-env-variables: ^1.0.1 => 1.0.1
gatsby-plugin-manifest: ^2.0.22 => 2.2.3
gatsby-plugin-react-helmet: ^3.0.8 => 3.1.2
gatsby-plugin-react-svg: ^2.1.1 => 2.1.1
gatsby-plugin-remote-images: ^1.0.1 => 1.0.3
gatsby-plugin-sass: ^2.0.11 => 2.1.3
gatsby-plugin-sharp: ^2.0.25 => 2.2.8
gatsby-plugin-typescript: ^2.1.0 => 2.1.2
gatsby-source-filesystem: ^2.0.23 => 2.1.5
gatsby-source-s3-image: ^1.5.8 => 1.6.5
gatsby-transformer-sharp: ^2.1.15 => 2.2.4
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 26
- Comments: 40 (4 by maintainers)
I worked around the issue by disabling the “Delete cookies and site data when Firefox Developer Edition is closed” option:
Just came across this error as well in Firefox 72.
A different option than unchecking the
Delete cookies and site data when Firefox is closed
is to leave it checked but then go intoManage Permissions
option next to the checkmark and addlocalhost:8000
to theAllow
list. Just adding localhost did not work for me, I had to specifically add the port as well.Yeah !!! This is the solution
The issue is that firefox doesn’t allow any kind of access to
navigator.serviceWorker
when the “delete cookies and site data when Firefox is closed” option is enabled. I don’t know what reasons did they have for it, but dealing with that issue would just be a matter of surrounding thenavigator.serviceWorker
access with atry ... catch
that captures theSecurityError
exception and proceeds as if the browser did not have any serviceWorker functionality.In case someone uses Firefox for anything else than just Gatsby development, I’d recommend against disabling cleaning the cookies on exit. I’m not sure about adding
localhost:8000
to the whitelist, because some popular malware (like the video conferencing app Zoom) install local servers that do stuff we wouldn’t want them to do.Whitelisting the
localhost:8000
would most definitely be a good temporary workaround, but that’s not really a solution.As far as I’ve seen, the Firefox team knows about this issue, but doesn’t consider it their problem: https://bugzilla.mozilla.org/show_bug.cgi?id=1429714. They have a good point that a rejected Promise should be handled gracefully, like any other possible error. I think @kilburn’s idea to add error handling for it would be a way towards a proper fix.
As a temporary workaround, the Incognito mode works fine.
Personally, I don’t want that functionality completely disabled.
Hope it helps 😄
Happening on MacOS FireFox 69.0, with FF extensions disabled, vanilla gatsby-starter-default.
It works as described. 👍
I submitted a minimal fix in #25981. I like @j127 's specific Firefox warning, but opted to omit it, thinking
I’m glad to retract the PR if we think there’s a better way, but wanted to get some active code in place that catches the exception and gives us a foundation for discussion.
Experiencing this too! FF 75.0 (64bit), on Ubuntu 18.04. My ‘workaround’ is to just comment out the entire if-statement’s body, but I have to do that everytime the development server restarts., which is not very convenient.
I am having this issue on
FF/Mac (v73.0.1)
andcreate-react-app
and it fixed it! But does anyone know why this happens?Thank you so much! This worked for the exact error I was having with my React app. But what exactly is the problem? And why does this work? Should the unregister function in my React app be changed to account for this in some way?
Same on firefox 69.0 (64-bit) for linux
Thanks! Oh and btw,
Manage Permissions
isManage Exceptions
onFDE 82
now.Thêm try catch hoặc .catch nhé các sếp 😃
Another workaround would be to set
dom.serviceWorkers.enabled
tofalse
inabout:config
.I’m not sure on the side-effects on this one, but so far I add an empty catch to the
navigator.serviceWorker.getRegistrations().then(...)
every time I rungatsby develop
Takes care of the annoying error for me.
I am also seeing this. One (very) slight difference between my case and OPs is the subsequent line is highlighted as the error in my case:
Also I am running FF Developer Edition 70.0b2
Not just nightly, I’m running
FF 69.0
.Just ran
gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world
and thengatsby develop
and see the same screen as above.I have FF’s security and privacy settings all turned on but wouldn’t expect that to effect this. Switched them all back to standard and still get this screen.