From 73ad68613cb00b1e852eb22c38c89287ca392088 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:34:45 -0800 Subject: [PATCH 1/2] test(cli): validate unusable releases with the production probe bound --- scripts/build-npm-launcher.test.ts | 107 ++++++++++++++--------------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/scripts/build-npm-launcher.test.ts b/scripts/build-npm-launcher.test.ts index 5facd9dabeb33..883f0f858f1c8 100644 --- a/scripts/build-npm-launcher.test.ts +++ b/scripts/build-npm-launcher.test.ts @@ -392,65 +392,60 @@ fs.readFileSync = (file, ...rest) => { ); }), ); - it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")( - "does not publish an unusable release", +}); + +for (const { name, executable } of [ + { name: "missing loader", executable: "#!/t3-test-missing-loader\n" }, + { + name: "loader failure", + executable: '#!/bin/sh\necho "runtime loader failed" >&2\nexit 42\n', + }, + { name: "terminated probe", executable: "#!/bin/sh\nkill -TERM $$\n" }, + { + name: "unresponsive probe", + executable: + '#!/bin/sh\ntrap \'echo caught > "$T3CODE_TEST_TERM"; exit 42\' TERM\necho ready > "$T3CODE_TEST_READY"\nwhile :; do :; done\n', + }, +]) { + it.live.skipIf(HostProcess.Platform.defaultValue() === "win32")( + `does not publish an unusable release: ${name}`, () => Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; - for (const executable of [ - "#!/t3-test-missing-loader\n", - '#!/bin/sh\necho "runtime loader failed" >&2\nexit 42\n', - "#!/bin/sh\nkill -TERM $$\n", - '#!/bin/sh\ntrap \'echo caught > "$T3CODE_TEST_TERM"; exit 42\' TERM\necho ready > "$T3CODE_TEST_READY"\nwhile :; do :; done\n', - ]) { - const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-npm-validation-test-" }); - const output = yield* buildNpmLauncher({ - version: VERSION, - outputDir: path.join(root, "out"), - }); - const release = yield* serveFakeRelease(root, executable); - const home = path.join(root, "home"); - const dir = path.join(home, "runtime/versions", VERSION); - const probeTimeoutHook = path.join(root, "probe-timeout.mjs"); - yield* fs.writeFileString( - probeTimeoutHook, - `import childProcess from "node:child_process"; -import { syncBuiltinESMExports } from "node:module"; -const { spawnSync } = childProcess; -childProcess.spawnSync = (command, args, options) => spawnSync(command, args, - options?.timeout === undefined ? options : { ...options, timeout: 500 }); -syncBuiltinESMExports(); -`, - ); - const env = { - PATH: (yield* HostProcess.Environment).PATH, - T3CODE_HOME: home, - T3CODE_RELEASE_BASE_URL: release.baseUrl, - T3CODE_TEST_READY: path.join(root, "probe-ready"), - T3CODE_TEST_TERM: path.join(root, "probe-term"), - }; - const launcher = path.join(output.packageDir, "bin/t3.mjs"); - const failed = yield* run( - process.execPath, - ["--import", probeTimeoutHook, launcher, "serve"], - { cwd: root, env }, - ); - assert.equal(failed.exitCode, 1, failed.stderr); - assert.deepStrictEqual(yield* fs.readDirectory(path.dirname(dir)), [], failed.stderr); - assert.include(failed.stderr, "could not run"); - if (executable.includes("runtime loader failed")) { - assert.include(failed.stderr, "runtime loader failed"); - } - if (executable.includes("trap")) { - assert.isTrue(yield* fs.exists(env.T3CODE_TEST_READY), failed.stderr); - assert.isFalse(yield* fs.exists(env.T3CODE_TEST_TERM)); - } - if ((yield* HostProcess.Platform) === "linux") { - assert.include(failed.stderr, "glibc"); - assert.include(failed.stderr, "musl"); - } + const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-npm-validation-test-" }); + const output = yield* buildNpmLauncher({ + version: VERSION, + outputDir: path.join(root, "out"), + }); + const release = yield* serveFakeRelease(root, executable); + const home = path.join(root, "home"); + const dir = path.join(home, "runtime/versions", VERSION); + const env = { + PATH: (yield* HostProcess.Environment).PATH, + T3CODE_HOME: home, + T3CODE_RELEASE_BASE_URL: release.baseUrl, + T3CODE_TEST_READY: path.join(root, "probe-ready"), + T3CODE_TEST_TERM: path.join(root, "probe-term"), + }; + const launcher = path.join(output.packageDir, "bin/t3.mjs"); + const failed = yield* run(process.execPath, [launcher, "serve"], { cwd: root, env }); + assert.equal(failed.exitCode, 1, failed.stderr); + assert.deepStrictEqual(yield* fs.readDirectory(path.dirname(dir)), [], failed.stderr); + assert.include(failed.stderr, "could not run"); + if (executable.includes("runtime loader failed")) { + assert.include(failed.stderr, "runtime loader failed"); } - }), + if (name === "terminated probe") assert.include(failed.stderr, "SIGTERM"); + if (executable.includes("trap")) { + assert.isTrue(yield* fs.exists(env.T3CODE_TEST_READY), failed.stderr); + assert.isFalse(yield* fs.exists(env.T3CODE_TEST_TERM)); + assert.include(failed.stderr, "ETIMEDOUT"); + } + if ((yield* HostProcess.Platform) === "linux") { + assert.include(failed.stderr, "glibc"); + assert.include(failed.stderr, "musl"); + } + }).pipe(Effect.provide(NodeServices.layer)), ); -}); +} From d0e2b679937d9054558a927abbedde07cb6d0e56 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:48:43 -0800 Subject: [PATCH 2/2] test(cli): idle the hanging probe while it awaits termination --- scripts/build-npm-launcher.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/build-npm-launcher.test.ts b/scripts/build-npm-launcher.test.ts index 883f0f858f1c8..9fb10fed0e3cd 100644 --- a/scripts/build-npm-launcher.test.ts +++ b/scripts/build-npm-launcher.test.ts @@ -403,8 +403,13 @@ for (const { name, executable } of [ { name: "terminated probe", executable: "#!/bin/sh\nkill -TERM $$\n" }, { name: "unresponsive probe", - executable: - '#!/bin/sh\ntrap \'echo caught > "$T3CODE_TEST_TERM"; exit 42\' TERM\necho ready > "$T3CODE_TEST_READY"\nwhile :; do :; done\n', + executable: `#!/bin/sh +trap 'echo caught > "$T3CODE_TEST_TERM"; exit 42' TERM +mkfifo "$T3CODE_TEST_READY.fifo" || exit 1 +exec 3<>"$T3CODE_TEST_READY.fifo" +echo ready > "$T3CODE_TEST_READY" +read -r unused <&3 +`, }, ]) { it.live.skipIf(HostProcess.Platform.defaultValue() === "win32")( @@ -437,7 +442,7 @@ for (const { name, executable } of [ assert.include(failed.stderr, "runtime loader failed"); } if (name === "terminated probe") assert.include(failed.stderr, "SIGTERM"); - if (executable.includes("trap")) { + if (name === "unresponsive probe") { assert.isTrue(yield* fs.exists(env.T3CODE_TEST_READY), failed.stderr); assert.isFalse(yield* fs.exists(env.T3CODE_TEST_TERM)); assert.include(failed.stderr, "ETIMEDOUT");