Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Firestore emulation doesn't work with hot reloading #189

Open
slifty opened this issue Oct 11, 2022 · 2 comments
Open

bug: Firestore emulation doesn't work with hot reloading #189

slifty opened this issue Oct 11, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@slifty
Copy link

slifty commented Oct 11, 2022

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

  1. Create a sveltekit project using firebase + an emulator
  2. Run npm run dev
  3. Edit the module that sets up firebase file
  4. Attempt to invoke a firestore transaction
  5. 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

@slifty slifty added the bug Something isn't working label Oct 11, 2022
@slifty
Copy link
Author

slifty commented Oct 11, 2022

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.

@jthegedus
Copy link
Owner

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 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants