Firebase-js-sdk: useFunctionsEmulator not working with region

Created on 9 Jan 2020  路  8Comments  路  Source: firebase/firebase-js-sdk

[REQUIRED] Describe your environment

  • Operating System version: Windows 10
  • Browser version: Chrome 79
  • Firebase SDK version: 7.6.1
  • Firebase Product: Functions

[REQUIRED] Describe the problem

Emulator url will be ignored and call to cloudfunctions.net instead when setting region.

Relevant Code:

firebase.functions().useFunctionsEmulator("http://localhost:5001");

// This will call to cloudfunctions.net
firebase.app().functions("asia-east2").httpsCallable(<FnName>);

// This will call to localhost
firebase.app().functions().httpsCallable(<FnName>);
functions feature request

Most helpful comment

Thanks for letting us know your workaround, @ThewBear. While this is currently an intended behavior, we'll treat this as a feature request and keep this open.

All 8 comments

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Thanks for reporting, @ThewBear. It looks like an intended behavior as it's meant to test the function locally, the region isn't being observed. It's not until you deploy it that you can invoke it in the given region. The deployed URL should have the region in the hostname part of the URL, not in the path as you get the emulator.

So my current workaround is

if (process.env.NODE_ENV === "development") {
  firebase.app().functions().httpsCallable(<FnName>);
} else {
  firebase.app().functions("asia-east2").httpsCallable(<FnName>);
}

I think it would be better if I can give a region and firebase ignores it when using emulator.
This is already working in firebase-functions.

Thanks for letting us know your workaround, @ThewBear. While this is currently an intended behavior, we'll treat this as a feature request and keep this open.

+1

+1 馃憤

+1

I was using firebase.functions().useFunctionsEmulator(environment.emulator) globally, so to keep the changes to a minimum I used this as a workaround:

firebase.app().functions(environment.emulator ? undefined : 'europe-west1').httpsCallable(<FnName>)
Was this page helpful?
0 / 5 - 0 ratings