Repository navigation
fix(cli): render says why a page's process ended without an answer, and names a failed send - #11543
Conversation
…s exits, and says why when none arrives
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Requesting changes for one test gap. Waiting for close, exiting 73 on a failed send, and the new no-answer messages all check out against the code.
Blocking
host-answer.test.mjs(lines 25-38) passes a copy ofhost-answer.mjsthat callsexit(0)before the send callback and after a failed send, so it does not prove "never 0" or "only after the send's callback" as the description says; let the fakesendholddone, assert thatexitis not called beforedoneruns, and assert thatexit.mock.callsis exactly[[0]]on success and[[HOST_EXIT.sendFailed]]on a failed or throwing send.
Non-blocking: make the folder removal in withHostStateFile best-effort, so that a cleanup error cannot replace a finished render; report the stderrTail that the state file already carries in the stage message; add stateFile to page-host.mjs's @input header; and remove the test's await-host-test-* scratch folder. CI has not run on this draft head yet.
Claims and files checked
- Claim: the outcome waits for the channel to close, so an answer in transit is read. Verified:
render-page.mjs:435-443, and the exit-first test fails when the decision moves back toexit. - Claim: Node can report the exit before an answer still in the channel. Not reproduced in real Linux runs. It is consistent with Node's
exitsemantics and is not false. - Claim: the old host exited 0 even when its send failed. Verified in the base
page-host.mjsanswer(). - Claim: the three new no-answer messages. Verified:
render-page.mjs:331-342andawait-host.test.mjs:81-121. - Claim: the host exits 0 only after the channel accepts the answer, a failed or throwing send exits 73, and the CLI names it. Verified in code:
host-answer.mjs:31-39andrender-page.mjs:309-311. - Claim: the host keeps a small state file with stage, time, memory and send phase. Verified:
page-host.mjs:51-65andpage-host.mjs:95. - Claim: the state file sits in a new temporary folder for each render, outside the project, and is removed after a pass or a fail. Verified:
render-page.mjs:379-386andawait-host.test.mjs:130-151. - Claim: no timeout, retry or concurrency change. Verified:
RENDER_TIMEOUT_MSandrunPageare unchanged. - Claim: the Changeset is an experimental patch for the CLI. Verified.
- Claim: the red-first case fails with the base's bare error when the outcome is decided on
exit. Verified by a mutation run. - Claim: the usual order still resolves, and each no-answer case and exit 73 gives its own message. Verified: 8 of 8 pass.
- Claim: the host-answer tests prove "never 0" and "only after the send's callback". False: a host that breaks both passes 5 of 5. The no-channel and single-answer cases are verified.
- Claim: the render suite and the two new files pass, 141 tests. Verified: 128 + 8 + 5.
- Claim: no CI impact. Verified: the new tests fall under the existing Node project's glob, and no workflow changes.
- Changeset: a rendered page no longer fails when its answer arrives after the exit. Verified for that event order.
- Changeset: under load, the CLI could see the exit first. Not reproduced on Linux, and not false.
- Changeset: the CLI waits until the channel has closed, and the error names the reason. Verified.
- Changeset: a failed send exits with its own code. True for the internal host process. The command still exits 1.
- File
.changeset/render-host-answer-in-flight.md: clear (wording note). - File
packages/cli/foundation/render/await-host.test.mjs: clear (scratch folder note). - File
packages/cli/foundation/render/host-answer.mjs: clear. - File
packages/cli/foundation/render/host-answer.test.mjs: blocking finding above. - File
packages/cli/foundation/render/host-exit.mjs: clear. - File
packages/cli/foundation/render/page-host.mjs: clear (header note). - File
packages/cli/foundation/render/render-page.mjs: clear (cleanup and stderr notes).
… callback; best-effort cleanup; the stage error keeps the last output
There was a problem hiding this comment.
Requesting changes for one Changeset fix. Waiting for close, exiting 73 on a failed send, and the new no-answer messages all check out against the code and tests, and the test gap from the earlier review is closed.
Blocking
- Miss:
.changeset/render-host-answer-in-flight.mdcredits no contributor, sopnpm check:changesetsfails on it (and with it Lint'scheck:repoand CI's release step once they run); add@cixzhangon its own line after the body, aspnpm changeset:newwrites it.
Non-blocking: the Changeset's last sentence describes the page's internal process, while astryx experimental render still exits 1, so it reads better as "the error now names a failed send"; afterEach(() => vi.useRealTimers()) in await-host.test.mjs and the sendError option in host-answer.test.mjs are unused; and page-host.mjs's @output could mention the state file. CI has not run on this draft head yet.
Claims and files checked
- Claim: the CLI decided the outcome on the host's exit, and Node can report that exit before an answer still in the channel. Plausible and consistent with how Node reports a child's exit; not reproduced with a real process. The fake-host test shows the old decision fails that order.
- Claim: the host also exited 0 whether or not its send succeeded. Verified in the base
page-host.mjsanswer(). - Claim: the outcome is decided on
close, after the channel has drained, through the exportedawaitHost. Verified:render-page.mjs:399-451; a real fork showsclosewaits for the channel's end. - Claim: the three new no-answer messages. Verified:
render-page.mjs:331-343andawait-host.test.mjs:82-137. - Claim: the host exits 0 only after the channel accepted the answer, exits 73 when the send fails or throws, and the CLI names it. Verified:
host-answer.mjs:35-44andrender-page.mjs:309-311. - Claim:
page-host.mjsusesmakeAnswerand keeps a small state file. Verified:page-host.mjs:46-65and:95. - Claim: the state file sits in a new folder under the system temporary folder for each render, never in the project, and is removed after a pass or a fail, best effort. Verified:
render-page.mjs:380-391andawait-host.test.mjs:147-168. - Claim: the stage error keeps the page's last stderr line. Verified:
render-page.mjs:338andawait-host.test.mjs:110-123. - Claim: no timeout, retry or concurrency change. Verified:
RENDER_TIMEOUT_MSandrunPageare unchanged. - Claim: the Changeset is an experimental patch for the CLI. Verified, but it credits no contributor (blocking finding).
- Claim: with the outcome decided on
exit, the exit-first test fails with the old bare error, and the other new cases each give their own message. Verified by a mutation run and 9 of 9 passing. - Claim: the host-answer tests pin the exact exit calls (
[[0]]after the callback,[[73]],[[72]], one answer). Verified: 5 of 5 pass. - Claim: a
makeAnswerthat callsexit(0)right aftersend()fails 3 of the 5 cases. Verified by a mutation run. - Claim: the existing render suite passes with the two new files, 142 tests. Verified: 128 + 9 + 5.
- Claim: no CI impact. Verified: the new tests fall under the existing Node test project, and no workflow changes.
- Changeset: a rendered page no longer fails when its answer arrives just after the exit. Verified for that event order.
- Changeset: under load, the CLI could notice the exit first. Not reproduced; not false.
- Changeset: the CLI waits until the channel has closed. Verified.
- Changeset: the error says why when no answer arrives. Verified.
- Changeset: a send that fails now exits with its own code. True for the page's internal process; the command still exits 1 (wording note).
- File
.changeset/render-host-answer-in-flight.md: blocking finding above (and a wording note). - File
packages/cli/foundation/render/await-host.test.mjs: clear (one leftover note). - File
packages/cli/foundation/render/host-answer.mjs: clear. - File
packages/cli/foundation/render/host-answer.test.mjs: clear (one unused option note). - File
packages/cli/foundation/render/host-exit.mjs: clear. - File
packages/cli/foundation/render/page-host.mjs: clear (header note). - File
packages/cli/foundation/render/render-page.mjs: clear.
… unused test bits
There was a problem hiding this comment.
Requesting changes for one lint fix. The Changeset credit and the earlier notes are fixed, and waiting for close, exiting 73 on a failed send and the new no-answer messages all check out against the code and tests. CI has not run on this draft head yet.
Blocking
- Miss: the three empty
catch {}blocks atpage-host.mjs:56,render-page.mjs:328andrender-page.mjs:389fail ESLint'sno-emptyrule, so the requiredlintcheck fails once CI runs; keep each block and put the reason it ignores the error inside it as a comment.
Claims and files checked
- Claim: the CLI decided the outcome on the host's exit, which Node can report before an answer still in the channel. Verified in the base
render-page.mjs(it settled onexit); the exit-first test fails with the old bare error when the decision moves back toexit. - Claim: a page that rendered could fail with a bare "ended without an answer (exit 0)" naming no stage, time or memory. Verified in the base
hostEndError. - Claim: the host exited 0 whether or not its send succeeded. Verified in the base
page-host.mjsanswer(). - Claim: the outcome is decided on
close, after the channel has drained, through the exportedawaitHost. Verified:render-page.mjs:399-451. - Claim: the three new no-answer messages, read from the host's state file. Verified:
render-page.mjs:322-344andawait-host.test.mjs:81-136. - Claim: the host exits 0 only after the channel accepted the answer, exits 73 when the send fails or throws, and the CLI names it. Verified:
host-answer.mjs:25-45andrender-page.mjs:309-311. - Claim:
page-host.mjsusesmakeAnswerand keeps a small state file. Verified:page-host.mjs:52-66and:96. - Claim: the state file sits in a new folder under the system temporary folder for each render, never in the project, and is removed after a pass or a fail, best effort. Verified:
render-page.mjs:380-391andawait-host.test.mjs:145-166. - Claim: the stage error keeps the page's last stderr line. Verified:
render-page.mjs:338andawait-host.test.mjs:109-122. - Claim: no timeout, retry or concurrency change. Verified:
RENDER_TIMEOUT_MSandrunPageare unchanged. - Claim: the Changeset is an experimental patch for the CLI. Verified:
.changeset/render-host-answer-in-flight.md, andpnpm check:changesetspasses. - Claim: with the outcome decided on
exit, the exit-first test fails with the old bare error, and each no-answer case gives its own message. Verified by a mutation run and 9 of 9 passing. - Claim: the host-answer tests pin the exact exit calls. Verified: 5 of 5 pass.
- Claim: a
makeAnswerthat callsexit(0)right aftersend()fails 3 of the 5 cases. Verified by a mutation run. - Claim: the existing render suite passes with the two new files, 142 tests. Verified: 128 + 9 + 5.
- Claim: no CI impact. Verified: no workflow changes, and the new tests fall under the existing Node test project.
- Changeset: a rendered page no longer fails when its answer arrives just after the exit. Verified for that event order (
await-host.test.mjs:40-52). - Changeset: under load, the CLI could notice the exit first. Not reproduced; consistent with how Node reports a child's exit, so not false.
- Changeset: the CLI waits until the channel has closed. Verified:
render-page.mjs:442. - Changeset: when no answer arrives, the error says why. Verified:
render-page.mjs:322-344. - Changeset: when the page's process cannot send its answer, the error says so. Verified:
render-page.mjs:309-311. - File
.changeset/render-host-answer-in-flight.md: clear. - File
packages/cli/foundation/render/await-host.test.mjs: clear. - File
packages/cli/foundation/render/host-answer.mjs: clear. - File
packages/cli/foundation/render/host-answer.test.mjs: clear. - File
packages/cli/foundation/render/host-exit.mjs: clear. - File
packages/cli/foundation/render/page-host.mjs: blocking finding above (line 56). - File
packages/cli/foundation/render/render-page.mjs: blocking finding above (lines 328 and 389).
There was a problem hiding this comment.
Requesting changes for one fix. The three lint errors from the last round are fixed, and waiting for close, exiting 73 on a failed send and the new no-answer messages all check out against the code and tests. CI has not run on this draft head yet.
Blocking
- Miss:
withHostStateFilemakes its folder withfs.mkdtempSyncoutside anytry(render-page.mjs:383), so wherever the system temporary directory is missing or read-only every render now fails withERR_UNKNOWNbefore it starts, while the base renders the same page there; make the folder best effort (on failure, calluse(undefined), which the host andnoMessageErroralready handle) and add a test wheremkdtempSyncthrows.
Claims and files checked
- Claim: the CLI decided the outcome on the host's exit event. Verified in the base
render-page.mjs, which settled onexit. - Claim: Node can report that exit before an answer still in the channel. Not reproduced with real processes; consistent with Node's documented
exitsemantics, and the exit-first test pins that order, so not false. - Claim: a page that rendered could fail with a bare "ended without an answer (exit 0)" naming no stage, time or memory. Verified in the base
hostEndError. - Claim: the host exited 0 whether or not its send succeeded. Verified in the base
page-host.mjsanswer(), whose send callback exits 0 with or without an error. - Claim: the outcome is decided on
close, after the channel has drained, through the exportedawaitHost. Verified:render-page.mjs:402-454,closeat line 445. - Claim: the three new no-answer messages are read from the host's state file. Verified:
render-page.mjs:322-346andawait-host.test.mjs:100-155. - Claim: the host exits 0 only after the channel accepted the answer, exits 73 when the send fails or throws, and the CLI names it. Verified:
host-answer.mjs:25-46andrender-page.mjs:309-311. - Claim:
page-host.mjsusesmakeAnswerand keeps a small state file. Verified:page-host.mjs:52-68and line 98. - Claim: the state file sits in a new folder under the system temporary folder for each render, never in the project. Verified:
render-page.mjs:382-385andawait-host.test.mjs:165-174. - Claim: the folder is removed after a pass or a fail, best effort. Verified:
render-page.mjs:386-393andawait-host.test.mjs:165-186; making the folder is not best effort (the blocking finding). - Claim: the stage error keeps the page's last stderr line. Verified:
render-page.mjs:340andawait-host.test.mjs:128-141. - Claim: no timeout, retry or concurrency change. Verified:
RENDER_TIMEOUT_MSandrunPageare unchanged. - Claim: the Changeset is an experimental patch for the CLI. Verified, and the Changeset check passes.
- Claim: with the outcome decided on
exit, the exit-first test fails with the old bare error. Verified by a mutation run. - Claim: the usual order still resolves, each no-answer case gives its own message, and exit 73 says the send failed. Verified: 9 of 9 pass.
- Claim: the state-file tests check the temporary folder and its removal after a pass and a fail. Verified: both pass.
- Claim: the host-answer tests pin the exact exit calls for success, a failed or throwing send, no channel, and one answer only. Verified: 5 of 5 pass.
- Claim: a
makeAnswerthat callsexit(0)right aftersend()fails 3 of the 5 cases. Verified by a mutation run. - Claim: the existing render suite passes with the two new files, 142 tests. Verified: 128 + 9 + 5.
- Claim: no CI impact. Verified: no workflow changes, and the new tests run in the existing Node test project.
- Changeset: a rendered page no longer fails when its answer arrives just after the exit. Verified for that event order (
await-host.test.mjs:59-71). - Changeset: under load, the CLI could notice the exit first. Not reproduced; consistent with how Node reports a child's exit, so not false.
- Changeset: the CLI waits until the channel has closed. Verified:
render-page.mjs:445. - Changeset: when no answer arrives, the error says why. Verified:
render-page.mjs:322-346. - Changeset: when the page's process cannot send its answer, the error says so. Verified:
render-page.mjs:309-311. - File
.changeset/render-host-answer-in-flight.md: clear. - File
packages/cli/foundation/render/await-host.test.mjs: clear. - File
packages/cli/foundation/render/host-answer.mjs: clear. - File
packages/cli/foundation/render/host-answer.test.mjs: clear. - File
packages/cli/foundation/render/host-exit.mjs: clear. - File
packages/cli/foundation/render/page-host.mjs: clear. - File
packages/cli/foundation/render/render-page.mjs: blocking finding above (line 383).
There was a problem hiding this comment.
Requesting changes for one description fix; the code needs none. The temporary-folder fallback from the last round is in: with a missing or read-only temporary directory the render now writes the page, and a new test covers it. Waiting for close, exiting 73 on a failed send and the new no-answer messages all check out against the code and tests. CI has not run on this draft head yet.
Blocking
- The description says
render.test.mjsand the two new files total 142 tests, but at this head they hold 143 (the new no-temporary-folder test atawait-host.test.mjs:157), and it still says a state-file folder is made for each render without mentioning the fallback atrender-page.mjs:391-396, so update the count and add one line for the fallback and its test.
Claims and files checked
- Claim: the CLI decided the outcome on the host's exit event. Verified in the base
render-page.mjs, which settled onexit. - Claim: Node can report that exit before an answer still in the channel. Not reproduced with real processes; consistent with Node's documented
exitsemantics, and the exit-first test fixes that order, so not false. - Claim: a rendered page could fail with a bare "ended without an answer (exit 0)" naming no stage, time or memory. Verified in the base
hostEndError. - Claim: the host exited 0 whether or not its send succeeded. Verified in the base
page-host.mjs, whose send callback exits 0 with or without an error. - Claim: the outcome is decided on
closethrough the exportedawaitHost. Verified:render-page.mjs:415-467,closeat line 458. - Claim: the three no-answer messages come from the host's state file. Verified:
render-page.mjs:322-346andawait-host.test.mjs:81-136. - Claim: the host exits 0 only after the channel accepted the answer, exits 73 when the send fails or throws, and the CLI names it. Verified:
host-answer.mjs:25-46andrender-page.mjs:309-311. - Claim:
page-host.mjsusesmakeAnswerand keeps a small state file. Verified:page-host.mjs:52-68and line 98. - Claim: the state file sits in a new per-render folder under the system temporary folder, never in the project, removed after a pass or a fail, best effort. Verified:
render-page.mjs:385-407andawait-host.test.mjs:146-188; the folder is skipped when none can be made, which the description does not say (the blocking finding). - Claim: the stage error keeps the page's last stderr line. Verified:
render-page.mjs:340andawait-host.test.mjs:109-122. - Claim: no timeout, retry or concurrency change. Verified:
RENDER_TIMEOUT_MSandrunPageare unchanged. - Claim: the Changeset is an experimental patch for the CLI. Verified, and the Changeset check passes.
- Claim: with the outcome decided on
exit, the exit-first test fails with the old bare error. Verified by a mutation run. - Claim: the usual order still resolves, each no-answer case gives its own message, and exit 73 says the send failed. Verified: the tests pass.
- Claim: the state-file tests check the temporary folder and its removal after a pass and a fail. Verified: both pass.
- Claim: the host-answer tests pin the exact exit calls for success, a failed or throwing send, no channel, and one answer only. Verified: 5 of 5 pass.
- Claim: a
makeAnswerthat exits 0 right aftersend()fails 3 of the 5 cases. Verified by a mutation run. - Claim: the render suite passes with the two new files, 142 tests. False: they pass, but hold 143 tests (128 + 10 + 5).
- Claim: no CI impact. Verified: no workflow changes, and the new tests run in the existing Node test project in milliseconds.
- Changeset: a rendered page no longer fails when its answer arrives just after the exit. Verified for that event order (
await-host.test.mjs:40-52). - Changeset: under load, the CLI could notice the exit first. Not reproduced; consistent with how Node reports a child's exit, so not false.
- Changeset: the CLI waits until the channel has closed. Verified:
render-page.mjs:458. - Changeset: when no answer arrives, the error says why. Verified wherever a temporary folder exists:
render-page.mjs:322-346. - Changeset: when the page's process cannot send its answer, the error says so. Verified:
render-page.mjs:309-311. - File
.changeset/render-host-answer-in-flight.md: clear. - File
packages/cli/foundation/render/await-host.test.mjs: clear. - File
packages/cli/foundation/render/host-answer.mjs: clear. - File
packages/cli/foundation/render/host-answer.test.mjs: clear. - File
packages/cli/foundation/render/host-exit.mjs: clear. - File
packages/cli/foundation/render/page-host.mjs: clear. - File
packages/cli/foundation/render/render-page.mjs: clear; its new fallback is the behavior the description misses.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this draft head yet, and it runs once the pull request is marked ready for review. The description now matches the code (143 tests and the no-temporary-folder fallback), and waiting for close, exiting 73 on a failed send and the new no-answer messages all check out against the code and tests. main has since made the same exit to close switch in #11590, so the branch now conflicts on the comment above host.once('close'): merge main, keep either comment, and the merged head gets its own review.
- Non-blocking: a render stopped by Ctrl+C or SIGTERM leaves its
astryx-render-*folder in the system temporary folder, because thefinallyinwithHostStateFilenever runs; removing the folder in the host'sdisconnecthandler fixes it (inline comment onpage-host.mjs:69).
Claims and files checked
- Claim: the CLI decided the outcome on the host's exit event. Verified in the base
render-page.mjs, which settled onexit. - Claim: Node can report that exit before an answer still in the channel. Not reproduced with real processes; consistent with how Node reports a child's exit, and the exit-first test fixes that order, so not false.
- Claim: a rendered page could fail with a bare "ended without an answer (exit 0)" naming no stage, time or memory. Verified in the base
hostEndError. - Claim: the host exited 0 whether or not its send succeeded. Verified in the base
page-host.mjs, whose send callback exits 0 with or without an error. - Claim: the outcome is decided on
closethrough the exportedawaitHost. Verified:render-page.mjs:415-467,closeat line 458. - Claim: the three no-answer messages come from the host's state file. Verified:
render-page.mjs:322-346andawait-host.test.mjs:81-136. - Claim: the host exits 0 only after the channel accepted the answer, exits 73 when the send fails or throws, and the CLI names it. Verified:
host-answer.mjs:25-46andrender-page.mjs:309-311. - Claim:
page-host.mjsusesmakeAnswerand keeps a small state file. Verified:page-host.mjs:52-68and line 98. - Claim: the state file sits in a new per-render folder under the system temporary folder, never in the project, removed after a pass or a fail, best effort. Verified:
render-page.mjs:385-407andawait-host.test.mjs:146-188. - Claim: without a temporary folder the render runs without the state file, as on the base, and a test covers it. Verified:
render-page.mjs:391-396andawait-host.test.mjs:157; renders with the folder missing or read-only write the page. - Claim: the stage error keeps the page's last stderr line. Verified:
render-page.mjs:340andawait-host.test.mjs:109-122. - Claim: no timeout, retry or concurrency change. Verified:
RENDER_TIMEOUT_MSandrunPageare unchanged. - Claim: the Changeset is an experimental patch for the CLI. Verified, and the Changeset check passes.
- Claim: with the outcome decided on
exit, the exit-first test fails with the old bare error. Verified by a mutation run. - Claim: the usual order still resolves, each no-answer case gives its own message, and exit 73 says the send failed. Verified: the tests pass.
- Claim: the state-file tests check the temporary folder and its removal after a pass and a fail. Verified: both pass.
- Claim: the host-answer tests pin the exact exit calls for success, a failed or throwing send, no channel, and one answer only. Verified: 5 of 5 pass.
- Claim: a
makeAnswerthat exits 0 right aftersend()fails 3 of the 5 cases. Verified by a mutation run. - Claim: the render suite passes with the two new files, 143 tests. Verified: 128 + 10 + 5 pass.
- Claim: no CI impact. Verified: no workflow changes, and the new tests run in the existing Node test project in milliseconds.
- Changeset: a rendered page no longer fails when its answer arrives just after the exit. Verified for that event order (
await-host.test.mjs:40-52). - Changeset: under load, the CLI could notice the exit first. Not reproduced; consistent with how Node reports a child's exit, so not false.
- Changeset: the CLI waits until the channel has closed. Verified:
render-page.mjs:458. - Changeset: when no answer arrives, the error says why. Verified wherever a temporary folder exists:
render-page.mjs:322-346. - Changeset: when the page's process cannot send its answer, the error says so. Verified:
render-page.mjs:309-311. - File
.changeset/render-host-answer-in-flight.md: clear. - File
packages/cli/foundation/render/await-host.test.mjs: clear. - File
packages/cli/foundation/render/host-answer.mjs: clear. - File
packages/cli/foundation/render/host-answer.test.mjs: clear. - File
packages/cli/foundation/render/host-exit.mjs: clear. - File
packages/cli/foundation/render/page-host.mjs: non-blocking note on thedisconnecthandler (line 69). - File
packages/cli/foundation/render/render-page.mjs: clear; it conflicts withmainonly on the comment abovehost.once('close').
| }); | ||
|
|
||
| saveState('no'); | ||
| process.once('disconnect', () => process.exit(HOST_EXIT.disconnected)); |
There was a problem hiding this comment.
Non-blocking: when the CLI is stopped by Ctrl+C, SIGTERM or SIGKILL (a caller's own time limit, say), withHostStateFile's finally never runs, so the astryx-render-* folder and its host-state.json stay in the system temporary folder; the render suite's two "ends the page process when the CLI is stopped" cases leave two on every run. This handler is the one place that still runs then, and exit 70 never reads the file, so it can remove the folder:
process.once('disconnect', () => {
// The CLI is gone and never reads the state file, so remove its folder.
if (input.stateFile) {
try {
fs.rmSync(path.dirname(input.stateFile), {recursive: true, force: true});
} catch {
// Best effort.
}
}
process.exit(HOST_EXIT.disconnected);
});With that change (and import * as path from 'node:path'), SIGINT, SIGTERM and SIGKILL each leave no folder.
# Conflicts: # packages/cli/foundation/render/render-page.mjs
There was a problem hiding this comment.
Requesting changes for one wording fix; the code needs none. The new no-answer reasons, the exit 73 on a failed send and the temporary-folder fallback check out, and the tests pass on this head.
- Regression: since the merge of
main, the title and the Changeset (.changeset/render-host-answer-in-flight.md:5) still claim the late-answer fix (waiting forclose) thatmainalready made in #11590, and the description calls theexitdecision "main's behavior" and points the fallback at lines 391–396 instead of 395–400.
Retitle to something like fix(cli): render says why a page's process ended without an answer, and names a failed send, keep only those two changes in the Changeset (moving the late-answer sentence to #11590's pending Changeset if the release note should keep it), and update the description. A render stopped by a signal still leaves its temporary folder behind; that note stays non-blocking.
Claims and files checked
- Claim: the outcome waits for
close, so an answer still in transit is read, andmainhas done so since #11590: verified (render-page.mjs:460-467; baserender-page.mjs:376-378). - Claim: the wait is the exported
awaitHost: verified (render-page.mjs:419). - Claim: with no answer, the error says sent but not received, ended while sending, or the stage, seconds and free memory: verified (
render-page.mjs:337-349;await-host.test.mjs:81-136). - Claim: the page's process exits 0 only after the channel accepts the answer, and 73 on a failed or throwing send, which the CLI names: verified (
host-answer.mjs:35-44;render-page.mjs:313-315;host-answer.test.mjs:25-68). - Claim: the page host uses
makeAnswerand keeps a state file of stage, time, memory and send phase: verified (page-host.mjs:52-68,:98). - Claim: the state file sits in a new per-render folder under the system temporary folder, never in the project, removed best effort after a passing or failing render: verified (
render-page.mjs:389-411;await-host.test.mjs:146-187). - Claim: without a temporary folder the render runs with no state file, and a test proves it: verified (
render-page.mjs:395-400;await-host.test.mjs:157); its pointer to lines 391–396: false at this head. - Claim: the host and the no-answer message treat the file as optional: verified (
page-host.mjs:53;render-page.mjs:331-335). - Claim: the stage error keeps the page's last stderr line: verified (
render-page.mjs:344). - Claim: no timeout, retry or concurrency change: verified (diff).
- Claim: the exit-first test fails with the bare error when the outcome is decided on
exit: verified (mutant run); calling thatmain's behavior: false (baserender-page.mjs:376-378). - Claim: the usual order still resolves, each no-answer case has its own message, and exit 73 says the send failed: verified (
await-host.test.mjs:54-65,:81-144). - Claim: the host-answer tests pin the exact exit calls, and a mutant exiting 0 after the send fails 3 of 5: verified (mutant run).
- Claim: the render API tests and the two new files pass, 143 tests: verified.
- Claim: no new CI job: verified.
- Changeset: render no longer fails a page whose answer arrives after its process exits, by waiting for the channel to close: false for this pull request (
mainalready does it). - Changeset: with no answer, the error says why, and a failed send is reported: verified.
- Changeset: an
[experimental]patch for@astryxdesign/cli, credited: verified (check:changesetspasses). - File
.changeset/render-host-answer-in-flight.md: finding (claims the late-answer fix). - File
packages/cli/foundation/render/await-host.test.mjs: clear. - File
packages/cli/foundation/render/host-answer.mjs: clear. - File
packages/cli/foundation/render/host-answer.test.mjs: clear. - File
packages/cli/foundation/render/host-exit.mjs: clear. - File
packages/cli/foundation/render/page-host.mjs: clear (non-blocking note on the signal leftover). - File
packages/cli/foundation/render/render-page.mjs: clear.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this draft head yet, and it runs once the pull request is marked ready for review. The title, the Changeset and the description now describe only what this change adds, and the new no-answer reasons, the exit 73 on a failed send and the temporary-folder fallback check out against the code and the tests.
- Non-blocking: a render stopped by Ctrl+C or SIGTERM still leaves its
astryx-render-*folder in the system temporary folder, because thefinallyinwithHostStateFilenever runs; removing the folder in the host'sdisconnecthandler fixes it (inline comment onpage-host.mjs:69).
Claims and files checked
- Claim: the released CLI decided the outcome on the host's
exitevent, so a rendered page could fail with the bare "ended without an answer (exit 0)", and the host exited 0 whether or not its send succeeded: verified (basepage-host.mjs:39; theexithandler #11590 replaced). - Claim: the outcome is decided on
close, so an answer still in transit is read;mainhas done so since #11590 and this keeps it: verified (render-page.mjs:460-469; baserender-page.mjs:376-378). - Claim: the wait is the exported
awaitHost: verified (render-page.mjs:419). - Claim: with no answer, the error says sent but not received, ended while sending, or the stage, seconds and free memory: verified (
render-page.mjs:337-349;await-host.test.mjs:81-142). - Claim: the page's process exits 0 only after the channel accepts the answer, and 73 on a failed or throwing send, which the CLI names: verified (
host-answer.mjs:35-44;host-exit.mjs:15;render-page.mjs:313-315;host-answer.test.mjs:25-67). - Claim: the page host uses
makeAnswerand keeps a state file of stage, time, memory and send phase: verified (page-host.mjs:52-68,:98). - Claim: the state file sits in a new per-render folder under the system temporary folder, never in the project, removed best effort after a passing or failing render: verified (
render-page.mjs:389-411;await-host.test.mjs:146-155,:178-187). - Claim: without a temporary folder the render runs with no state file (lines 395-400), the host and the no-answer message treat the file as optional, and a test proves it: verified (
render-page.mjs:395-400,:331-335;page-host.mjs:53;await-host.test.mjs:157). - Claim: the stage error keeps the page's last stderr line: verified (
render-page.mjs:344;await-host.test.mjs:109-122). - Claim: no timeout, retry or concurrency change: verified (diff;
RENDER_TIMEOUT_MSandrunPageunchanged). - Claim: the exit-first test fails with the old bare error when the outcome is decided on
exit, as before #11590, and passes onclose; the decision is #11590's: verified (mutation run; baserender-page.mjs:376-378). - Claim: the usual order still resolves, each no-answer case has its own message, and exit 73 says the send failed: verified (
await-host.test.mjs:54-64,:81-142). - Claim: the host-answer tests pin the exact exit calls (0 only after the callback, 73 on a failed or throwing send, 72 with no channel, one answer), and a version that exits 0 right after the send fails 3 of 5: verified (
host-answer.test.mjs:25-82; mutation run). - Claim: the render API tests and the two new files pass, 143 tests: verified.
- Claim: no new CI job; the new files run in the Node test project: verified (no workflow change;
vitest.config.ts:252). - Changeset: with no answer, the error says why (sent but not received, ended while sending, or the stage, seconds and free memory): verified (
render-page.mjs:337-349). - Changeset: when the page's process cannot send its answer, the error says so: verified (
render-page.mjs:313-315). - Changeset: an
[experimental]patch for@astryxdesign/cli, credited: verified (the Changeset check passes). - File
.changeset/render-host-answer-in-flight.md: clear. - File
packages/cli/foundation/render/await-host.test.mjs: clear. - File
packages/cli/foundation/render/host-answer.mjs: clear. - File
packages/cli/foundation/render/host-answer.test.mjs: clear. - File
packages/cli/foundation/render/host-exit.mjs: clear. - File
packages/cli/foundation/render/page-host.mjs: clear (non-blocking note on the signal leftover). - File
packages/cli/foundation/render/render-page.mjs: clear.
This is the follow-up for the guardian's render row: the "ended without an answer (exit 0)" failures with no stage named.
Who this helps
Anyone running
astryx experimental renderon a loaded machine, CI included. The CLI decided a page's outcome on its host process'sexitevent. Node can report that exit before an answer that is still in the channel. So a page that rendered could fail with "The page's process ended without an answer (exit 0)", with no stage, time or memory named, because the host had answered and the CLI had not yet read it. The host also exited 0 whether or not its send succeeded.What changes
packages/cli/foundation/render/render-page.mjs: the outcome is decided onclose, which comes only after the channel has drained, so an answer still in transit is read.mainhas decided onclosesince [experimental] render: a rendered file explains itself, and --reverse names edits made after the render #11590; this keeps that, and its tests cover it. The wait is the exportedawaitHost(host, …). When the host ends with no answer reaching the CLI, the error now says why, from the host's state file:host-answer.mjs(new): the host's one answer, with send and exit passed in. It exits 0 only after the channel accepted the answer. A send that fails or throws exits with its own code,HOST_EXIT.sendFailed(73), and the CLI names it: "could not send its answer to this process".page-host.mjs: usesmakeAnswer, and keeps a small state file (stage, elapsed time, memory, and whether it is sending or has sent its answer).withHostStateFilemakes under the system's temporary folder (os.tmpdir()) for each render, never in the user's project. The folder is removed after the render, whether it passes or fails. The removal is best effort, so a file still held open never replaces the render's own result.withHostStateFilegivesundefinedand the render runs without the state file, as onmain(render-page.mjslines 395–400); the host and the no-answer message already treat the file as optional. A test makes the folder fail to create and checks that the render still returns its result with no state file (await-host.test.mjs:157)..changeset/render-host-answer-in-flight.md: a patch for@astryxdesign/cli, tagged[experimental]becauserenderis an experimental command.Red-first
packages/cli/foundation/render/await-host.test.mjsuses a fake host, so the order of its events is fixed and no case needs load:exit, asmainwas before [experimental] render: a rendered file explains itself, and --reverse names edits made after the render #11590, the test fails with the old bare error:The page's process ended without an answer (exit 0).Decided onclose, asmainnow is and this keeps, the answer is taken. This pull request adds the test that holds that decision in place; the decision itself is [experimental] render: a rendered file explains itself, and --reverse names edits made after the render #11590's.host-answer.test.mjs: the fake send holds its callback, so each case pins the exact exit calls:[[0]];[[73]], never 0;[[72]];A mutant
makeAnswerthat callsexit(0)right aftersend()fails 3 of these 5 cases.The existing
packages/cli/api/render/render.test.mjspasses, with the two new files: 143 tests (the no-temporary-folder case included).CI impact
None: +0 jobs. Two new test files in the Node project, a few milliseconds.
Owning session: noopbot (a61f66c2), under CI & Release (ca77f950). Land path: the shipper, through merge-guard.