Repository navigation
fix(generate): answer as soon as the module loader has a verdict - #92
Merged
csdev19 merged 2 commits intoOct 25, 2026
Conversation
…the module loader Refs NIW2-332 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The loader waited for the child to exit before reading its verdict, so a
module that left a timer, pool or watcher running was reported as a 10 s
timeout even though the child had already answered correctly.
The verdict is now one framed line carrying a per-load token. The parent
reads it incrementally, resolves, and kills the child; the child also exits
in its write callback. The parent resolves only after the child has exited,
so no orphan outlives the promise. The framing replaces lastIndexOf on
'{"ok":', which a nested value inside a schema could fool.
Refs NIW2-332
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
csdev19
deleted the
feature/niw2-332-module-loader-reports-a-valid-schema-module-as-a-10-s
branch
October 25, 2026 04:05
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed and why
A project module that exports a valid Standard Schema but leaves the event loop alive (a
setInterval, a DB pool, a file watcher) was reported as{"code":"timeout"}after about 10 s. The child had already printed the correct verdict, but the parent only read stdout inchild.on('close'), which never fires while the child stays alive.Changes in
packages/generate/src/load-module.ts:process.exit(0)in the stdout write callback, and the parent also sendsSIGKILL. The promise resolves only after the child'sexit, so no orphan outlives it.@laqi-verdict:<uuid>:). This replacesout.lastIndexOf('{"ok":'), which a nested{"ok":inside a schema'sexamplescould fool. JSON never holds a raw newline, so the line is unambiguous, and a module cannot print a matching line without reading this process's environment.Tests were written first and committed before the fix (
0483fe1). Two failed against the old loader (timer, nested{"ok":); the third (a module printing a verdict-shaped line) passed before and guards the new framing.Not in this PR (all NIW2-310): minimal child env, stdout/stderr caps, fd 3 framing, approval changes. The new tests only observe behaviour through
loadModuleSchema, so they should survive that rewrite.How I verified it
bun run test packages/generate/src/load-module.test.ts: 13/13 pass (the two new failing tests fail on the old loader).oxlint,oxfmt --check,bun run build,bun run check-types,bun run check-types:scripts,bun run test.bun run verifyitself exits 1 in the worker's worktree becauseoxfmt --check .flags.claude/skills/.gc-skill-ownership.json, an untracked, git-ignored file Gas City generates there. CI never sees it. I ran the same steps withoxfmt --check . '!.claude/**'.--frozen-lockfile.How to test it yourself
/tmp/timer.mjs:mainit takes about 10 s and returnscode: 'timeout'. On this branch it returns{ ok: true, ... }in well under a second, andpsshows no leftovernode -echild.bun run test packages/generate/src/load-module.test.ts.Refs NIW2-332
Run: Gas City session ni-wisp-ycl2jo6, bead la-2fl, Mac mini
🤖 Generated with Claude Code