-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
fix(build): packed tarball boot crash — server-ws timeout import escaped the package (#7065 class) #7308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix(build): packed tarball boot crash — server-ws timeout import escaped the package (#7065 class) #7308
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - **Build**: the packed tarball boots again — #7191's `../../src/…runtimeTimeouts.ts` import in `standalone-server-ws.mjs` escaped the package after the dist-root copy (`ERR_MODULE_NOT_FOUND` on every boot, #7065 class, caught live by the new `check:pack-boot` gate); the helper now lives in the shipped sibling `main-server-timeouts.mjs` (parity-tested against the canonical TS implementation) and the closure test bans package-escaping `../` imports in npm-shipped wrappers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Main-server keepAlive/headers timeouts (#7003) — SIBLING module of | ||
| // standalone-server-ws.mjs. The shipped server-ws.mjs may only import | ||
| // siblings copied next to it by assembleStandalone (peer-stamp, tls-options, | ||
| // the guards): a ../../src/... import resolves OUTSIDE the package after the | ||
| // copy to the dist root and crashes boot with ERR_MODULE_NOT_FOUND (caught | ||
| // live by check:pack-boot on 2026-07-15 — the #7065 class). | ||
| // Parity with src/shared/utils/runtimeTimeouts.ts#getMainServerTimeoutConfig | ||
| // is enforced by tests/unit/main-server-timeouts-parity.test.ts. | ||
|
|
||
| export const DEFAULT_MAIN_SERVER_KEEPALIVE_TIMEOUT_MS = 65_000; | ||
| export const DEFAULT_MAIN_SERVER_HEADERS_TIMEOUT_MS = 66_000; | ||
|
|
||
| function readTimeoutMs(env, name, defaultValue, { allowZero = false, logger } = {}) { | ||
| const raw = env[name]; | ||
| if (raw == null || raw.trim() === "") return defaultValue; | ||
| const parsed = Number(raw); | ||
| const isValid = Number.isFinite(parsed) && (allowZero ? parsed >= 0 : parsed > 0); | ||
| if (!isValid) { | ||
| logger?.(`Invalid ${name}="${raw}". Using default ${defaultValue}ms.`); | ||
| return defaultValue; | ||
| } | ||
| return Math.floor(parsed); | ||
| } | ||
|
|
||
| export function getMainServerTimeoutConfig(env = process.env, logger) { | ||
| const keepAliveTimeoutMs = readTimeoutMs( | ||
| env, | ||
| "MAIN_SERVER_KEEPALIVE_TIMEOUT_MS", | ||
| DEFAULT_MAIN_SERVER_KEEPALIVE_TIMEOUT_MS, | ||
| { allowZero: true, logger } | ||
| ); | ||
| const headersTimeoutMs = readTimeoutMs( | ||
| env, | ||
| "MAIN_SERVER_HEADERS_TIMEOUT_MS", | ||
| DEFAULT_MAIN_SERVER_HEADERS_TIMEOUT_MS, | ||
| { allowZero: true, logger } | ||
| ); | ||
| return { | ||
| keepAliveTimeoutMs, | ||
| // Node requires headersTimeout > keepAliveTimeout; keep both configurable | ||
| // but always coherent (mirrors the canonical TS implementation). | ||
| headersTimeoutMs: | ||
| headersTimeoutMs > 0 && keepAliveTimeoutMs > 0 | ||
| ? Math.max(headersTimeoutMs, keepAliveTimeoutMs + 1_000) | ||
| : headersTimeoutMs, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import test from "node:test"; | ||
| import assert from "node:assert"; | ||
| import { getMainServerTimeoutConfig as mjsImpl } from "../../scripts/dev/main-server-timeouts.mjs"; | ||
| import { getMainServerTimeoutConfig as tsImpl } from "../../src/shared/utils/runtimeTimeouts.ts"; | ||
|
|
||
| // The shipped server-ws.mjs uses the SIBLING scripts/dev/main-server-timeouts.mjs | ||
| // (a ../../src import escapes the package after the dist copy — 2026-07-15 boot | ||
| // crash, #7065 class). This parity matrix is the anti-drift guard between the | ||
| // sibling and the canonical src/shared/utils/runtimeTimeouts.ts implementation. | ||
| const ENV_MATRIX: Record<string, string | undefined>[] = [ | ||
| {}, | ||
| { MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: "70000" }, | ||
| { MAIN_SERVER_HEADERS_TIMEOUT_MS: "80000" }, | ||
| { MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: "90000", MAIN_SERVER_HEADERS_TIMEOUT_MS: "10000" }, | ||
| { MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: "0", MAIN_SERVER_HEADERS_TIMEOUT_MS: "0" }, | ||
| { MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: "abc" }, | ||
| { MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: " " }, | ||
| { MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: "-5" }, | ||
| { MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: "1234.9" }, | ||
| ]; | ||
|
|
||
| test("sibling main-server-timeouts.mjs stays in parity with runtimeTimeouts.ts", () => { | ||
| for (const env of ENV_MATRIX) { | ||
| assert.deepStrictEqual( | ||
| mjsImpl(env), | ||
| tsImpl(env), | ||
| `divergence for env ${JSON.stringify(env)}` | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| test("invalid values log through the provided logger in both implementations", () => { | ||
| const logsA: string[] = []; | ||
| const logsB: string[] = []; | ||
| mjsImpl({ MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: "bogus" }, (m) => logsA.push(m)); | ||
| tsImpl({ MAIN_SERVER_KEEPALIVE_TIMEOUT_MS: "bogus" }, (m) => logsB.push(m)); | ||
| assert.strictEqual(logsA.length, 1); | ||
| assert.deepStrictEqual(logsA, logsB); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current
parentRelativeImportshelper checks for static imports withfrom, dynamicimport(), and CommonJSrequire(). However, it misses side-effect imports of the formimport "../foo"(without afromclause). If a wrapper uses a side-effect import pointing to a parent-relative path, it will escape the package and cause a boot crash, bypassing this regression guard.Adding a pattern to match side-effect imports ensures complete coverage.