Uh oh!
There was an error while loading. Please reload this page.
fix(functions): store CLOUD_TASKS_EMULATOR_HOST at construction time - #3167
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the FunctionsApiClient to cache the CLOUD_TASKS_EMULATOR_HOST environment variable at construction time rather than reading it dynamically from process.env during execution. This cached value is then propagated to FunctionsHttpClient and helper functions, and corresponding unit tests have been added and updated. The feedback suggests improving the robustness of the environment variable parsing by trimming whitespace and treating empty strings as undefined, as well as simplifying the unit tests by utilizing a single stub with sequential call assertions instead of manual stub restoration.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Historically,
CLOUD_TASKS_EMULATOR_HOSTwas read fromprocess.envon every individual API call. This made it impossible to safely run one Firebase app pointing to the local emulator and another pointing to a real project concurrently.This pull request resolves the issue by caching the value of
CLOUD_TASKS_EMULATOR_HOSTonce when theFunctionsApiClientis constructed. The configuration is stored per-instance, ensuring that each client retains its own independent emulator setup.Based on a patch contribution #3059 (comment)