Skip to content

[firebase-vscode] CLI version check reads the version from the debug banner, because logSetup() leaks DEBUG=true into the spawned firebase --version (follow-up to #10874) #11363

Open

Description

@vgerasymenko

[REQUIRED] Environment info

firebase-tools: 15.33.0 (global npm install); Firebase Data Connect for VS Code 2.4.3, and the current main of firebase-vscode/src/extension.ts

Platform: Windows 11

[REQUIRED] Test case

logSetup() in firebase-vscode/src/logger-wrapper.ts sets process.env.DEBUG = "true". checkCLIInstallation() in firebase-vscode/src/extension.ts then spawns firebase --version with env = { ...process.env, VSCODE_CWD: "" }, so the CLI sees DEBUG=true and prints its debug banner on stdout before the version:

[2026-10-24T18:16:05.021Z] ----------------------------------------------------------------------
[2026-10-24T18:16:05.0xxZ] Command:       ...\firebase-tools\lib\bin\firebase.js --version
[2026-10-24T18:16:05.0xxZ] CLI Version:   15.33.0
...
15.33.0

[REQUIRED] Steps to reproduce

  1. Run firebase --version with DEBUG=true in the environment, and save stdout.
  2. Pass it to the version parsing in checkCLIInstallation(): semver.valid(out) || semver.coerce(out)?.version.

[REQUIRED] Expected behavior

The check reads 15.33.0, and warns when the installed CLI is older than npm's latest.

[REQUIRED] Actual behavior

With semver 7.8.5, on the stdout above:

  • semver.valid(out) is null;
  • semver.coerce(out)?.version is 2026.0.0, the year of the banner's first timestamp.

In 2.4.3, which parses with semver.valid() alone, this shows "The Firebase CLI is not installed (or not available on $PATH)" on every activation. #10874 (unreleased so far) adds the coerce fallback, which hides that warning, but the version it reads is 2026.0.0. So the "outdated version" warning can never fire while DEBUG leaks, and the logged version is wrong.

Suggested fix: remove DEBUG from the env of the spawned check (const env = { ...process.env, VSCODE_CWD: "" }; delete env.DEBUG;), or keep the extension's logging flag out of process.env, since it reaches every child process the extension starts. Earlier report of the same warning on Windows: #7910.

Activity

  1. added
    api: dataconnect
    VSCode Extension
    on Oct 26, 2026
  2. added and removed
    api: dataconnect
    on Oct 27, 2026
  3. aalej commented on Oct 27, 2026

    @aalej
    Contributor

    Thanks for the thorough report and for debugging the issue @vgerasymenko! I think your observations are correct. When the DEBUG env var is set to true, the output of running firebase --version will include the debug banner, which causes us to incorrectly parse the version.

    I think a minimal code that reproduces this behavior would look like

    minimal code
    const { spawnSync } = require("child_process");
    const semver = require("semver")
    
    // set DEBUG env
    process.env.DEBUG = true
    
    // parts vs-code code to determine firebase-tools version
    // see https://github.com/firebase/firebase-tools/blob/855f140c7b55cd46e4ff00f030a1d1268b42f1d0/firebase-vscode/src/extension.ts#L94-L117
    const env = { ...process.env, VSCODE_CWD: "" };
    const isWin = process.platform === "win32";
    const shell = process.env.SHELL || "/bin/bash";
    const spawnOptions = isWin ? { env, shell: true } : { env };
    
    const runCommand = (cmd) => {
      if (isWin) {
        return spawnSync(cmd, spawnOptions);
      }
      return spawnSync(shell, ["-l", "-c", cmd], spawnOptions);
    };
    
    const versionRes = runCommand("firebase --version");
    const versionStdout = versionRes.status === 0 ? versionRes.stdout?.toString().trim() : "";
    const currentVersion = versionStdout
      ? (semver.valid(versionStdout) || semver.coerce(versionStdout)?.version)
      : undefined;
    
    console.log(versionRes.stdout.toString()) // outputs full logs that include that debug banner
    
    console.log(currentVersion) // outputs 2026.0.0

    I'll raise this issue to our engineering team and mark it as reproducible. Since it looks like you've correctly identified the root cause, feel free to open up a PR for this if you're up for it! Otherwise, someone from our engineering team will take a look into this shortly.

  4. vgerasymenko commented on Oct 27, 2026

    @vgerasymenko
    Author

    Two simple proposals are presented above, not sure which one better aligns with the extension logic regarding child processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    VSCode Extensionreproducibletype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions