Closed GuasaPlay closed 3 years ago
I was facing the same issue. This is my workaround.
basically, I uncomment the emulator lines in development and comment them back out before deploy
// snippet from nuxt-firebase settings found in nuxt-config.js
firestore: {
enablePersistence: true
// emulatorPort: process.env.NODE_ENV !== 'production' ? 8080 : undefined,
// emulatorHost: 'localhost'
}
// nuxt-config.js
render: {
bundleRenderer: {
runInNewContext: false
}
},
ssr: true,
firebase: {
config: {
// config
},
services: {
auth: {
ssr: true,
persistence: 'local',
initialize: {
onAuthStateChangedMutation: null,
onAuthStateChangedAction: 'user/SET_AUTH_USER'
}
},
firestore: {
enablePersistence: true
// emulatorPort: process.env.NODE_ENV !== 'production' ? 8080 : undefined,
// emulatorHost: 'localhost'
}
}
},
With this setup, I'm able to bind to docs running in the emulator during development, and bind to the actual firestore in production
@GuasaPlay @miketierce I can't really reproduce this issue, could you create a sample project on https://template.nuxtjs.org/ (Codesandbox) where this issue appears so I can debug accordingly?
Are you sure you have the newest version of Firebase & nuxtjs/firebase installed and don't import Firebase anywhere else in your project?
Oh my. I think I am importing Firebase into the login component as well.
I'll try cleaning that up first.
@miketierce could you explain more about this?
I have the same problem as @miketierce. When I have "firestore / enablePersistence" option to true (and emulatorHost / emulatorPort configured). I have the error message : Firestore has already been started and its settings can no longer be changed.
For bypass the problem I set firestore => enablePersistence to false in development mode.
I have try to reproduce it on codesandbox as @lupas asked. But I have a others problem when I install firebase dependance on codesandbox : https://codesandbox.io/s/pedantic-shockley-wluw9?file=/package.json (Not relevance)
+1 This is still an issue.
It turns out I had a few other places in my code that I was still importing and using firebase instead of using this.$fire
Removing those additional import statements solved the problem for me.
@tibs245 & @buwilliams are you guys sure you're not importing Firebase somewhere else in your project?
This module imports Firebase for you, you shouldn't be importing Firebase yourself additionally.
@lupas As far as I can tell (manually going through all the code as well as grepping) the answer is no. All I need to do is enablePersistence
to get this error. It may help to know this is not a SSR project.
firestore: {
enablePersistence: {
synchronizeTabs: true
},
emulatorPort: process.env.NODE_ENV === 'development' ? 8080 : undefined,
}
@lupas Yes I am sure. I have do search on all project file and I not found import.
Hey @tibs245 & @buwilliams
Thanks for your inputs! Found the issue and fixed it with https://github.com/nuxt-community/firebase-module/commit/bc16b45a712e3c6400f7c9f8fa1af4233679b46c, will release in a new version asap.
Issue was that we called useEmulator() before enablePersistence(). Switching that order works perfectly without throwing the error.
@lupas I'm impressed you took the time to dig in and solve it. I'd say this is a +1 for your character
sir. I hope you have an extra nice Friday!
Hello everyone.
I have a problem when I try to use the emulator in firestore. In previous issues #390 #116 they have the same problem, I followed the same steps to correct the problem but it still shows me the error. Maybe you can help me with something that I am doing wrong This is my config in nuxt.config.js