Skip to content

cannot disconnect function from emulator after using connectFunctionsEmulator #7895

@Yukinosuke-Takada

Description

@Yukinosuke-Takada

Operating System

macOS 14.0

Browser Version

Chrome Version 117.0.5938.149 (Official Build) (arm64)

Firebase SDK Version

firebase v 10.7.0, @firebase/functions v 0.11.0

Firebase SDK Product:

Functions

Describe your project's tooling

I'm using firebase/function in my webapp.

My mac is running node v19.7.0, yarn 1.22.19

Describe the problem

I have a web app that tests Firebase functions. It tests the onCall function on the Emulator and Deployed in the same run. After using connectFunctionsEmulator(), The specified function will use the Emulator afterward (even if I don't call connectFunctionsEmulator).

Steps and code to reproduce issue

Code:

  const invokeWithFunctionName = async (
    environment: Environment,
    functionRegion: string,
    functionName: string,
    sendingParameters: Record<string, string>
  ) => {
    const firebaseFunctions: Functions = getFunctions(currentApp, functionRegion);
    if (environment === 'Emulator') {
      connectFunctionsEmulator(firebaseFunctions, 'localhost', 5001);
    } else {
      // disconnect emulator
      
    }
    const callable = httpsCallable(firebaseFunctions, functionName, { timeout: 10000 });
    const res = await callable(sendingParameters);
    return (res.data as string);
  };
await invokeWithFunctionName('Deployed', 'asia-northeast1', 'f', {});
await invokeWithFunctionName('Emulator', 'asia-northeast1', 'f', {});
await invokeWithFunctionName('Deployed', 'asia-northeast1', 'f', {});

The POST request it's sending

POST https://asia-northeast1-****.cloudfunctions.net/f
POST http://localhost:5001/****/asia-northeast1/f
POST http://localhost:5001/****/asia-northeast1/f

See that the 3rd POST request is stuck with using localhost.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions