Skip to content

Commit

Permalink
fix: slow startup if no network is available (#5055)
Browse files Browse the repository at this point in the history
* fix: add timeouts to npm commands

To prevent slow startups if no network is available

* chore: update npm command timeout

Co-authored-by: Cole Rogers <colerogers@users.noreply.github.com>
  • Loading branch information
stfsy and colerogers committed Jan 31, 2023
1 parent 0c64e8e commit 06ec3c1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/deploy/functions/runtimes/node/versioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import * as fs from "fs";
import * as path from "path";

import * as clc from "colorette";
import * as semver from "semver";
import * as spawn from "cross-spawn";
import * as semver from "semver";

import * as utils from "../../../../utils";
import { logger } from "../../../../logger";
import { track } from "../../../../track";
import * as utils from "../../../../utils";

interface NpmShowResult {
"dist-tags": {
Expand All @@ -16,6 +16,7 @@ interface NpmShowResult {
}

const MIN_SDK_VERSION = "2.0.0";
const NPM_COMMAND_TIMEOUT_MILLIES = 10000;

export const FUNCTIONS_SDK_VERSION_TOO_OLD_WARNING =
clc.bold(clc.yellow("functions: ")) +
Expand Down Expand Up @@ -88,6 +89,7 @@ export function getFunctionsSDKVersion(sourceDir: string): string | undefined {
export function getLatestSDKVersion(): string | undefined {
const child = spawn.sync("npm", ["show", "firebase-functions", "--json=true"], {
encoding: "utf8",
timeout: NPM_COMMAND_TIMEOUT_MILLIES,
});
if (child.error) {
logger.debug(
Expand Down

0 comments on commit 06ec3c1

Please sign in to comment.