-
Notifications
You must be signed in to change notification settings - Fork 1k
Functions useEmulator not persistent between regions #3537
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
Comments
thanks @epodol for reporting this. @kmcnellis can you please take a look at this? |
I have looked into this some more and created a basic html/js only example. Here are a few and some conclusions I came to. ExamplesExample 1: firebase.initializeApp(firebaseConfig);
const functions = firebase.functions();
functions.useEmulator('localhost', 5001)
functions.httpsCallable('test')() Example 1 calls: Example 2: firebase.initializeApp(firebaseConfig);
const functions = firebase.app().functions('us-west2');
functions.useEmulator('localhost', 5001)
functions.httpsCallable('test')() Example 2 calls Example 3: firebase.initializeApp(firebaseConfig);
const functions = firebase.app().functions('us-west2');
firebase.app().functions().useEmulator('localhost', 5001)
firebase.app().functions().httpsCallable('test')() Example 3 calls Example 4: firebase.initializeApp(firebaseConfig);
const functions = firebase.app().functions('us-west2');
firebase.app().functions('us-west2').useEmulator('localhost', 5001)
firebase.app().functions('us-west2').httpsCallable('test')() Example 4 calls Example 5: firebase.initializeApp(firebaseConfig);
const functions = firebase.app().functions('us-west2');
functions.useEmulator('localhost', 5001)
firebase.app().functions().httpsCallable('test')() Example 5 calls Example 6: firebase.initializeApp(firebaseConfig);
const functions = firebase.app().functions('us-west2');
functions.useEmulator('localhost', 5001)
firebase.app().functions('us-west2').httpsCallable('test')() Example 6 calls ConclusionsCalling I'm not sure if this is actually a bug with Firebase anymore, but I think there could be some improvement with how Firebase handles custom regions. Ideally, the region could be defined as an option/argument in the same Currently, the best solution for me is to use Example 6 since I am using reactfire. For example: import { useAuth, useFirebaseApp } from 'reactfire';
// ...
const functions = useFirebaseApp().functions('us-west2');
// ...
await functions
.httpsCallable('addNewUser')({
// ... If this is all intended behavior, then you can close this issue/change the title. Thank you! |
I think @samtstern is the most familiar with this code. |
But I think basically the issue is in how the useEmulator function interacts with the firebase.app().functions(). The example#5 above, calling production:
The line Additionally, there is a layer of caching of the functions instance using the ComponentContainer, that will return that same 'us-west2' instance of functions each time So when you then call |
I think it's probably working as designed, but the design seems quite confusing/unintuitive to me. |
Thank you @kmcnellis! That is the conclusion I came to as well. I appreciate the help! |
@kmcnellis has nailed it. This is working as designed, and the design is confusing 🤦 For all of our SDKs we decided that Closing as this is not a bug, although I take it as feedback and I'll think about ways to improve this without breaking people! |
[REQUIRED] Environment info
firebase-tools: 9.14.0
Platform: Windows with WSL 2 Ubuntu
[REQUIRED] Test case
React and Reactfire are being used in this project. The repo is available at https://github.com/epodol/bsclibrary.
[REQUIRED] Steps to reproduce
functions()
with a custom region as depicted here: https://firebase.google.com/docs/functions/locations#client-side_location_selection_for_callable_functionsuseEmulator()
call onto thefunctions()
with a region, it will result in both the region and the emulator call being ignored.[REQUIRED] Expected behavior
The emulator should still work when a custom region is defined.
[REQUIRED] Actual behavior
May be related to #3031, #3364, #3418
The text was updated successfully, but these errors were encountered: