Skip to content

Commit 06ec3c1

Browse files
stfsycolerogers
andauthored
fix: slow startup if no network is available (#5055)
* 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>
1 parent 0c64e8e commit 06ec3c1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/deploy/functions/runtimes/node/versioning.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import * as fs from "fs";
22
import * as path from "path";
33

44
import * as clc from "colorette";
5-
import * as semver from "semver";
65
import * as spawn from "cross-spawn";
6+
import * as semver from "semver";
77

8-
import * as utils from "../../../../utils";
98
import { logger } from "../../../../logger";
109
import { track } from "../../../../track";
10+
import * as utils from "../../../../utils";
1111

1212
interface NpmShowResult {
1313
"dist-tags": {
@@ -16,6 +16,7 @@ interface NpmShowResult {
1616
}
1717

1818
const MIN_SDK_VERSION = "2.0.0";
19+
const NPM_COMMAND_TIMEOUT_MILLIES = 10000;
1920

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

0 commit comments

Comments
 (0)