svelte-adapter-firebase
svelte-adapter-firebase copied to clipboard
bug: Firestore emulation doesn't work with hot reloading
Describe the Bug
I think this may be an issue with sveltekit but since this repository represents the blend of sveltekit and firebase it seemed like an appropriate place to document the problem
I have a firebase.ts file configures a connection to firebase. It connects to the emulator if it detects a development environment. This works fine, but if the firebase module is edited while running in development mode / with hot module replacement it results in an error:
Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.
Here is the code just for the record:
const firebaseConfig = {...};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
if (env.NODE_ENV !== 'production') {
console.log(env);
console.log('Using Firestore Emulator');
connectFirestoreEmulator(
db,
'localhost',
8080,
);
}
Steps to Reproduce
- Create a sveltekit project using firebase + an emulator
- Run
npm run dev - Edit the module that sets up firebase file
- Attempt to invoke a firestore transaction
- See the error
Expected Behaviour
I would expect the firestore emulation configuration to continue to work.
svelte-adapter-firebase version
0.14.4
sveltejs/kit version
1.0.0-next.488
Understood if this ends up being considered irrelevant to this repository, but I thought creating the issue might help others. At this point the only solution I could find is to manually restart npm run dev instead of relying on hot module reloading.
I might not be able to actually tackle this issue with the adapter separate from the Firebase framework. Firebase have added official support for Web Frameworks, so this adapter might end up being deprecated if they add support there.
Thanks for sharing your solution / workaround :pray: