From 1a3c5a3cbd3749ed448425f474b2dbbcb78d4f73 Mon Sep 17 00:00:00 2001 From: Leonardo Ortiz Date: Sun, 17 Sep 2023 23:56:23 -0300 Subject: [PATCH 1/3] increase npm root timeout to 5s --- src/frameworks/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frameworks/utils.ts b/src/frameworks/utils.ts index c0d3bf04703..b84a525c0b0 100644 --- a/src/frameworks/utils.ts +++ b/src/frameworks/utils.ts @@ -24,7 +24,7 @@ import { BUILD_TARGET_PURPOSE, RequestHandler } from "./interfaces"; // the import statement into a require const { dynamicImport } = require(true && "../dynamicImport"); -const NPM_ROOT_TIMEOUT_MILLIES = 2_000; +const NPM_ROOT_TIMEOUT_MILLIES = 5_000; /** * Whether the given string starts with http:// or https:// From fb11ddcfe2e5e8061724720a5d9b854299486c80 Mon Sep 17 00:00:00 2001 From: Leonardo Ortiz Date: Sun, 17 Sep 2023 23:59:59 -0300 Subject: [PATCH 2/3] memoize npm root --- src/frameworks/utils.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/frameworks/utils.ts b/src/frameworks/utils.ts index b84a525c0b0..0aafbc845fa 100644 --- a/src/frameworks/utils.ts +++ b/src/frameworks/utils.ts @@ -25,6 +25,7 @@ import { BUILD_TARGET_PURPOSE, RequestHandler } from "./interfaces"; const { dynamicImport } = require(true && "../dynamicImport"); const NPM_ROOT_TIMEOUT_MILLIES = 5_000; +const NPM_ROOT_MEMO = new Map(); /** * Whether the given string starts with http:// or https:// @@ -222,9 +223,19 @@ function scanDependencyTree(searchingFor: string, dependencies = {}): any { } export function getNpmRoot(cwd: string) { - return spawnSync("npm", ["root"], { cwd, timeout: NPM_ROOT_TIMEOUT_MILLIES }) + let npmRoot = NPM_ROOT_MEMO.get(cwd); + if (npmRoot) return npmRoot; + + npmRoot = spawnSync("npm", ["root"], { + cwd, + timeout: NPM_ROOT_TIMEOUT_MILLIES, + }) .stdout?.toString() .trim(); + + NPM_ROOT_MEMO.set(cwd, npmRoot); + + return npmRoot; } export function getNodeModuleBin(name: string, cwd: string) { From 2eb65fe59282a3a3a5b35b0af86a5656f75cbfc8 Mon Sep 17 00:00:00 2001 From: Leonardo Ortiz Date: Mon, 18 Sep 2023 12:14:29 -0300 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29bb2d..e6e144b702a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1 @@ +- Fix "Could not find the next executable" on Next.js deployments (#6372)