Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed
- `npm run release:verify` stopped `npm test` after 15 minutes and reported it as `release verification failed: npm test: > @youdie006/prodex@0.40.51 test`, npm's banner line, as if a test had failed. Found 2026-11-10, when this stopped the 0.40.51 publish run on its macOS Intel runner with no test failed; CI's macOS Intel runners had taken 10.5 to 14 minutes for the suite. The suite now gets 25 minutes, `PRODEX_RELEASE_CHECK_TEST_TIMEOUT_MS` sets another budget in milliseconds, and a check stopped at its budget is reported as stopped, with the budget.
- The test that a browser prodex cannot reach is closed waited a fixed 200 ms for the closed browser's exit to be reported, and failed the same publish run on its Windows runner, where the report came later. It now waits for the exit itself, up to 5 seconds.

## 0.40.51

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm run typecheck

## Before opening a pull request

- `npm run release:verify` must pass — it chains tests, typecheck, build, package smoke, and `doctor`.
- `npm run release:verify` must pass — it chains tests, typecheck, build, package smoke, and `doctor`. The tests get 25 minutes; on a slower machine set `PRODEX_RELEASE_CHECK_TEST_TIMEOUT_MS` (milliseconds).
- Add tests for new behavior; the codebase favors test-first where practical.
- Keep changes focused and small.
- Code comments, commit messages, and docs are written in **English**.
Expand Down
30 changes: 29 additions & 1 deletion scripts/release-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,18 @@ async function readRequiredPackageJson(packageJsonPath) {
// evidence, because the process died before it printed anything - while running
// the same command directly passed every check. CI runs this same path before
// publishing, so the cap was a thin margin in the release path too.
//
// The suite's own budget was 15 minutes, while CI's macOS Intel runners took
// 10.5 to 14 minutes for it. On 2026-11-10 the 0.40.51 publish run's runner
// needed more, and `npm test` was stopped at 15:00 with nothing failed. It now
// gets 25 minutes, still inside CI's 40 minute job limit with the other checks.
async function runFullReleaseVerification(rootDir) {
// Declared here, not at module scope: this file runs its entry point during
// module evaluation, so a top-level const is still in its temporal dead zone
// by the time this is called.
const CHECK_TIMEOUT_MS = {
default: 300_000,
"npm test": 900_000,
"npm test": testTimeoutMs(),
"npm run smoke:package": 1_800_000
};
const checks = [
Expand Down Expand Up @@ -349,9 +354,24 @@ function formatPathList(paths) {
return paths.length > 8 ? `${shown}, ... (${paths.length} files)` : shown;
}

function testTimeoutMs() {
const raw = process.env.PRODEX_RELEASE_CHECK_TEST_TIMEOUT_MS;
if (raw === undefined || raw.trim() === "") return 1_500_000;
const value = Number(raw);
if (!Number.isInteger(value) || value <= 0) {
throw new Error(`release verification failed: PRODEX_RELEASE_CHECK_TEST_TIMEOUT_MS must be a whole number of milliseconds, got ${JSON.stringify(raw)}`);
}
return value;
}

function formatBudget(ms) {
return ms < 120_000 ? `${Math.round(ms / 1000)} s` : `${Math.round(ms / 60_000)} min`;
}

async function run(command, commandArgs, cwd, timeoutMs = 300_000) {
const commandLine = [command, ...commandArgs].join(" ");
console.log(`release_check: ${commandLine}`);
const startedAt = Date.now();
try {
const execute = command === "npm"
? execNpm(commandArgs, {
Expand All @@ -370,6 +390,14 @@ async function run(command, commandArgs, cwd, timeoutMs = 300_000) {
// stderr line, which npm noise ("npm warn ...") could occupy while the
// actual test failure sat in stdout and was silently dropped.
printCapturedOutputTail(error, commandLine);
// A check stopped at its budget has failed nothing yet; its first output
// line (npm's "> package@version test" banner) read like the failure.
if (error && typeof error === "object" && error.killed === true && Date.now() - startedAt >= timeoutMs) {
const hint = commandLine === "npm test" ? " On a slower machine, raise PRODEX_RELEASE_CHECK_TEST_TIMEOUT_MS (milliseconds)." : "";
throw new Error(
`release verification failed: ${commandLine}: stopped after its ${formatBudget(timeoutMs)} time budget, before it finished; the output it printed is above.${hint}`
);
}
throw new Error(`release verification failed: ${commandLine}: ${commandFailureDetail(error)}`);
}
}
Expand Down
17 changes: 12 additions & 5 deletions tests/launch-port-unavailable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ async function freePort(): Promise<number> {
return port;
}

function launched(port: number): { launch: ChatGptBrowserLaunch; alive: () => boolean } {
function launched(port: number): { launch: ChatGptBrowserLaunch; endedWithin: (ms: number) => Promise<boolean> } {
const child = spawn(process.execPath, ["-e", "setTimeout(() => {}, 60000)"], { stdio: "ignore" });
const ended = new Promise<true>((resolve) => child.once("exit", () => resolve(true)));
const launch: ChatGptBrowserLaunch = {
command: "chrome",
args: [],
Expand All @@ -39,7 +40,10 @@ function launched(port: number): { launch: ChatGptBrowserLaunch; alive: () => bo
port,
waitForEarlyExit: async () => undefined
};
return { launch, alive: () => child.exitCode === null && child.signalCode === null };
return {
launch,
endedWithin: (ms) => Promise.race([ended, new Promise<false>((resolve) => setTimeout(() => resolve(false), ms))])
};
}

describe("a browser launch whose DevTools endpoint never appears", () => {
Expand All @@ -52,9 +56,12 @@ describe("a browser launch whose DevTools endpoint never appears", () => {
});

it("ends the browser it started, so the next attempt is not refused as a wedged one", async () => {
const { launch, alive } = launched(await freePort());
const { launch, endedWithin } = launched(await freePort());
await expect(assertBrowserLaunchStayedAlive(launch, 300)).rejects.toThrow(/did not expose a reachable DevTools endpoint/);
await new Promise((resolve) => setTimeout(resolve, 200));
expect(alive()).toBe(false);
// The browser is gone when that returns, but its exit reaches this process
// as an event. A fixed 200 ms wait for it failed on the 0.40.51 publish
// run's Windows runner (2026-11-10); the event is awaited instead. A browser
// left running would still fail this, as it lives for 60 s.
expect(await endedWithin(5_000)).toBe(true);
});
});
46 changes: 41 additions & 5 deletions tests/release-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,29 @@ describe("release-check", () => {
expect(result.stderr).not.toContain("Command failed:");
expect(result.stderr).not.toContain("Node.js v");
});

// Found 2026-11-10: the 0.40.51 publish run stopped `npm test` on its macOS
// Intel runner when the 15 minute budget ran out, and reported it as
// "release verification failed: npm test: > @youdie006/prodex@0.40.51 test",
// npm's banner line, as if a test had failed.
it("says a check was stopped at its time budget instead of quoting its first line", async () => {
const root = await copyPackageJsonToTemp();
const npmCommand = expectedNpmCommand();
const fakeCommands = await createFakeReleaseCommands(root, { hangCommand: `${npmCommand}\ttest` });

const result = await runReleaseCheck(root, {
verificationOnly: true,
pathPrefix: fakeCommands.binDir,
logPath: fakeCommands.logPath,
env: { PRODEX_RELEASE_CHECK_TEST_TIMEOUT_MS: "1500" }
});

expect(result.code).toBe(1);
expect(result.stderr).toContain(`release verification failed: ${npmCommand} test: stopped after its 2 s time budget`);
expect(result.stderr).toContain("PRODEX_RELEASE_CHECK_TEST_TIMEOUT_MS");
expect(result.stderr).not.toContain("failed: npm test: > ");
expect(result.stdout).not.toContain(`release_check: ${npmCommand} run typecheck`);
});
});

async function copyPackageJsonToTemp(): Promise<string> {
Expand Down Expand Up @@ -649,7 +672,7 @@ function expectedNpmCommand(): "npm" {

async function createFakeReleaseCommands(
root: string,
options: { failCommand?: string; packStdout?: string; silentFail?: boolean } = {}
options: { failCommand?: string; hangCommand?: string; packStdout?: string; silentFail?: boolean } = {}
): Promise<{ binDir: string; logPath: string }> {
const binDir = path.join(root, "fake-bin");
const logPath = path.join(root, "release-check-commands.log");
Expand All @@ -673,11 +696,19 @@ async function createFakeReleaseCommands(
"utf8"
);
await chmod(path.join(root, "dist", "cli.js"), 0o755);
await writeFakeCommand(npmCliPath, "npm", logPath, options.failCommand, options.packStdout ?? defaultPackStdout, options.silentFail);
await writeFakeCommand(npmCliPath, "npm", logPath, options.failCommand, options.packStdout ?? defaultPackStdout, options.silentFail, options.hangCommand);
return { binDir, logPath };
}

async function writeFakeCommand(filePath: string, command: string, logPath: string, failCommand?: string, packStdout?: string, silentFail = false): Promise<void> {
async function writeFakeCommand(
filePath: string,
command: string,
logPath: string,
failCommand?: string,
packStdout?: string,
silentFail = false,
hangCommand?: string
): Promise<void> {
await writeFile(
filePath,
[
Expand All @@ -689,6 +720,10 @@ async function writeFakeCommand(filePath: string, command: string, logPath: stri
...(silentFail ? [] : [` console.error("fake release-check command failed: " + commandLine);`]),
" process.exit(42);",
"}",
`if (commandLine === ${JSON.stringify(hangCommand ?? "")}) {`,
` console.log("> @youdie006/prodex@0.0.0 " + process.argv.slice(2).join(" "));`,
" setTimeout(() => {}, 60_000);",
"}",
`if (${JSON.stringify(command === "npm")} && process.argv[2] === "pack") {`,
` console.log(${JSON.stringify(packStdout ?? JSON.stringify([{ files: [{ path: "package.json", mode: 420 }, { path: "LICENSE", mode: 420 }, { path: "dist/cli.js", mode: 493 }] }]))});`,
"}"
Expand All @@ -711,7 +746,7 @@ function normalizePackagePath(value: string): string {

async function runReleaseCheck(
root: string,
options: { metadataOnly?: boolean; verificationOnly?: boolean; pathPrefix?: string; logPath?: string } = {}
options: { metadataOnly?: boolean; verificationOnly?: boolean; pathPrefix?: string; logPath?: string; env?: Record<string, string> } = {}
): Promise<{ code: number; stdout: string; stderr: string }> {
const args = [path.join(repoRoot, "scripts", "release-check.mjs")];
if (options.verificationOnly) args.push("--verification-only");
Expand All @@ -721,7 +756,8 @@ async function runReleaseCheck(
...process.env,
...(options.pathPrefix ? { PATH: `${options.pathPrefix}${path.delimiter}${process.env.PATH ?? ""}` } : {}),
...(options.pathPrefix ? { npm_execpath: path.join(options.pathPrefix, "npm-cli.mjs") } : {}),
...(options.logPath ? { PRODEX_RELEASE_CHECK_LOG: options.logPath } : {})
...(options.logPath ? { PRODEX_RELEASE_CHECK_LOG: options.logPath } : {}),
...options.env
};
try {
const result = await execFileAsync(process.execPath, args, {
Expand Down
Loading