Comments (6)
@Jmyerzzz, service worker doesn't yet support modularization. To use the latest version of the SDK, please use the compat version when importing the script. With that, I'll be closing the ticket now. If the issue persists, feel free to comment and reopen this issue.
/**
* Here is is the code snippet to initialize Firebase Messaging in the Service
* Worker when your app is not hosted on Firebase Hosting.
// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here. Other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/10.11.1/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/10.11.1/firebase-messaging-compat.js');
from firebase-js-sdk.
One quick check first: if you start up your dev server and navigate in your browser to http://localhost:3000/firebase-messaging-sw.js
, do you get a 404?
from firebase-js-sdk.
Hi @Jmyerzzz, I'm unable to reproduce the same behavior you're experiencing. But to add from what hsubox76 said. Usually this error is thrown because of runtime error in the sw script. If you could provide us a minimal repro, it'll help us out to a faster resolution. Thanks!
from firebase-js-sdk.
Actually, to clarify, the 404 error is not thrown because of an error in the sw script, but if the sw script isn't there at all, i.e., if you navigate there using your browser's url field, you get a 404. There's a different error thrown if there's an error in the sw script that ends with the string "ServiceWorker script evaluation failed".
from firebase-js-sdk.
Thanks for the help here, I was able to resolve this by adding to my webpack config
plugins: [
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, './public/firebase-messaging-sw.js'),
to: path.resolve(__dirname, './build/firebase-messaging-sw.js'),
},
],
}),
],
The error I'm now running into is SyntaxError: Cannot use import statement outside a module (at firebase-messaging-sw.js:1:1)
. I can resolve this by changing the file extension to .mjs
in that webpack config but it then seems messaging doesn't work because firebase is expecting that specific file name.
I know this error is separate from the issue reported, so lmk if I should open a new one
from firebase-js-sdk.
It looks like the initial issue was already solved. I'll be closing this issue now. If you encounter another issue, feel free to create a new one.
from firebase-js-sdk.
Related Issues (20)
- Cannot invoke HttpsCallable functions on Safari HOT 5
- `User.getIdToken(true)` fails with quota exceeded HOT 1
- ID token docs say refreshes with 5 minutes buffer but seems to be 30 seconds HOT 2
- Document references from another DB cause error logs HOT 2
- Support offline memoryLocalCache persistence for node HOT 3
- Expo: Unable to resolve "./index.shared" from "node_modules/@firebase/auth/dist/index.rn.d.ts" HOT 2
- Upgrade from 9.10.0 to 10.11.0 leads to 46kB increase in bundle size HOT 3
- All remote config param values are not returned on App A but are returned on App B HOT 3
- Firestore experimentalAutoDetectLongPolling/experimentalForceLongPolling does not work as expected HOT 11
- FIRESTORE (10.9.0) INTERNAL ASSERTION FAILED: Unexpected state HOT 4
- getToken() for Push API, requires Notification API support HOT 6
- FIrebase Storage Offline is possible according to Gemini HOT 1
- getDoc() is never resolved nor rejected using Remix and Firestore Lite HOT 4
- App Check fails after returning to an inactive background tab
- FirebaseError: Missing or insufficient permissions. HOT 9
- MISSING_OR_INVALID_NONCE : The nonce in ID Token does not match the SHA256 hash of the raw nonce in the request
- The accessToken property is missing in the User interface HOT 1
- Analytics Consent not sent on update HOT 4
- Cross-Origin-Opener-Policy policy would block the window.closed call. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebase-js-sdk.