Skip to content

fix(cli): render says why a page's process ended without an answer, and names a failed send - #11543

Merged
cixzhang merged 11 commits into
mainfrom
fix/render-host-answer
Nov 14, 2026
Merged

cixzhang merged 11 commits into
mainfrom
fix/render-host-answer

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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 render on a loaded machine, CI included. The CLI decided a page's outcome on its host process's exit event. 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 on close, which comes only after the channel has drained, so an answer still in transit is read. main has decided on close since [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 exported awaitHost(host, …). When the host ends with no answer reaching the CLI, the error now says why, from the host's state file:
    • "sent its answer, but this process did not receive it";
    • "ended while it sent its answer";
    • "ended without an answer (exit N) while , after S seconds, with F MB of memory free".
  • 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: uses makeAnswer, and keeps a small state file (stage, elapsed time, memory, and whether it is sending or has sent its answer).
  • The state file lives in a new folder that withHostStateFile makes 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.
  • Without a temporary folder (missing or read-only), withHostStateFile gives undefined and the render runs without the state file, as on main (render-page.mjs lines 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).
  • The "ended while " error keeps the page's last stderr line, as the existing no-answer error does.
  • No timeout, retry or concurrency change.
  • .changeset/render-host-answer-in-flight.md: a patch for @astryxdesign/cli, tagged [experimental] because render is an experimental command.

Red-first

packages/cli/foundation/render/await-host.test.mjs uses a fake host, so the order of its events is fixed and no case needs load:

host-answer.test.mjs: the fake send holds its callback, so each case pins the exact exit calls:

  • success: no exit before the callback, then exactly [[0]];
  • a failed or throwing send: exactly [[73]], never 0;
  • no channel: [[72]];
  • only one answer is ever sent.

A mutant makeAnswer that calls exit(0) right after send() fails 3 of these 5 cases.

The existing packages/cli/api/render/render.test.mjs passes, 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.

@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 14, 2026 12:19am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2026
@astracat-bot

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 14, 2026, 12:25 AM UTC

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · ef18372

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 4.30 MB packed (+2.3 kB); no new dependencies.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 of host-answer.mjs that calls exit(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 fake send hold done, assert that exit is not called before done runs, and assert that exit.mock.calls is 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 to exit.
  • 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 exit semantics and is not false.
  • Claim: the old host exited 0 even when its send failed. Verified in the base page-host.mjs answer().
  • Claim: the three new no-answer messages. Verified: render-page.mjs:331-342 and await-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-39 and render-page.mjs:309-311.
  • Claim: the host keeps a small state file with stage, time, memory and send phase. Verified: page-host.mjs:51-65 and page-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-386 and await-host.test.mjs:130-151.
  • Claim: no timeout, retry or concurrency change. Verified: RENDER_TIMEOUT_MS and runPage are 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).

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md credits no contributor, so pnpm check:changesets fails on it (and with it Lint's check:repo and CI's release step once they run); add @cixzhang on its own line after the body, as pnpm changeset:new writes 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.mjs answer().
  • Claim: the outcome is decided on close, after the channel has drained, through the exported awaitHost. Verified: render-page.mjs:399-451; a real fork shows close waits for the channel's end.
  • Claim: the three new no-answer messages. Verified: render-page.mjs:331-343 and await-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-44 and render-page.mjs:309-311.
  • Claim: page-host.mjs uses makeAnswer and keeps a small state file. Verified: page-host.mjs:46-65 and :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-391 and await-host.test.mjs:147-168.
  • Claim: the stage error keeps the page's last stderr line. Verified: render-page.mjs:338 and await-host.test.mjs:110-123.
  • Claim: no timeout, retry or concurrency change. Verified: RENDER_TIMEOUT_MS and runPage are 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 makeAnswer that calls exit(0) right after send() 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.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 at page-host.mjs:56, render-page.mjs:328 and render-page.mjs:389 fail ESLint's no-empty rule, so the required lint check 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 on exit); the exit-first test fails with the old bare error when the decision moves back to exit.
  • 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.mjs answer().
  • Claim: the outcome is decided on close, after the channel has drained, through the exported awaitHost. 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-344 and await-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-45 and render-page.mjs:309-311.
  • Claim: page-host.mjs uses makeAnswer and keeps a small state file. Verified: page-host.mjs:52-66 and :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-391 and await-host.test.mjs:145-166.
  • Claim: the stage error keeps the page's last stderr line. Verified: render-page.mjs:338 and await-host.test.mjs:109-122.
  • Claim: no timeout, retry or concurrency change. Verified: RENDER_TIMEOUT_MS and runPage are unchanged.
  • Claim: the Changeset is an experimental patch for the CLI. Verified: .changeset/render-host-answer-in-flight.md, and pnpm check:changesets passes.
  • 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 makeAnswer that calls exit(0) right after send() 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).

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: withHostStateFile makes its folder with fs.mkdtempSync outside any try (render-page.mjs:383), so wherever the system temporary directory is missing or read-only every render now fails with ERR_UNKNOWN before it starts, while the base renders the same page there; make the folder best effort (on failure, call use(undefined), which the host and noMessageError already handle) and add a test where mkdtempSync throws.
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 on exit.
  • Claim: Node can report that exit before an answer still in the channel. Not reproduced with real processes; consistent with Node's documented exit semantics, 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.mjs answer(), whose send callback exits 0 with or without an error.
  • Claim: the outcome is decided on close, after the channel has drained, through the exported awaitHost. Verified: render-page.mjs:402-454, close at line 445.
  • Claim: the three new no-answer messages are read from the host's state file. Verified: render-page.mjs:322-346 and await-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-46 and render-page.mjs:309-311.
  • Claim: page-host.mjs uses makeAnswer and keeps a small state file. Verified: page-host.mjs:52-68 and 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-385 and await-host.test.mjs:165-174.
  • Claim: the folder is removed after a pass or a fail, best effort. Verified: render-page.mjs:386-393 and await-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:340 and await-host.test.mjs:128-141.
  • Claim: no timeout, retry or concurrency change. Verified: RENDER_TIMEOUT_MS and runPage are 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 makeAnswer that calls exit(0) right after send() 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).

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.mjs and the two new files total 142 tests, but at this head they hold 143 (the new no-temporary-folder test at await-host.test.mjs:157), and it still says a state-file folder is made for each render without mentioning the fallback at render-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 on exit.
  • Claim: Node can report that exit before an answer still in the channel. Not reproduced with real processes; consistent with Node's documented exit semantics, 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 close through the exported awaitHost. Verified: render-page.mjs:415-467, close at line 458.
  • Claim: the three no-answer messages come from the host's state file. Verified: render-page.mjs:322-346 and await-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-46 and render-page.mjs:309-311.
  • Claim: page-host.mjs uses makeAnswer and keeps a small state file. Verified: page-host.mjs:52-68 and 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-407 and await-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:340 and await-host.test.mjs:109-122.
  • Claim: no timeout, retry or concurrency change. Verified: RENDER_TIMEOUT_MS and runPage are 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 makeAnswer that exits 0 right after send() 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.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the finally in withHostStateFile never runs; removing the folder in the host's disconnect handler fixes it (inline comment on page-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 on exit.
  • 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 close through the exported awaitHost. Verified: render-page.mjs:415-467, close at line 458.
  • Claim: the three no-answer messages come from the host's state file. Verified: render-page.mjs:322-346 and await-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-46 and render-page.mjs:309-311.
  • Claim: page-host.mjs uses makeAnswer and keeps a small state file. Verified: page-host.mjs:52-68 and 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-407 and await-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-396 and await-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:340 and await-host.test.mjs:109-122.
  • Claim: no timeout, retry or concurrency change. Verified: RENDER_TIMEOUT_MS and runPage are 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 makeAnswer that exits 0 right after send() 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 the disconnect handler (line 69).
  • File packages/cli/foundation/render/render-page.mjs: clear; it conflicts with main only on the comment above host.once('close').

Automated review (maintainer link)

});

saveState('no');
process.once('disconnect', () => process.exit(HOST_EXIT.disconnected));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 for close) that main already made in #11590, and the description calls the exit decision "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, and main has done so since #11590: verified (render-page.mjs:460-467; base render-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 makeAnswer and 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 that main's behavior: false (base render-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 (main already 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:changesets passes).
  • 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.

Automated review (maintainer link)

@cixzhang cixzhang changed the title fix(cli): render takes an answer that arrives after the page's process exits, and says why when none arrives fix(cli): render says why a page's process ended without an answer, and names a failed send Nov 14, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the finally in withHostStateFile never runs; removing the folder in the host's disconnect handler fixes it (inline comment on page-host.mjs:69).
Claims and files checked
  • Claim: the released CLI decided the outcome on the host's exit event, 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 (base page-host.mjs:39; the exit handler #11590 replaced).
  • Claim: the outcome is decided on close, so an answer still in transit is read; main has done so since #11590 and this keeps it: verified (render-page.mjs:460-469; base render-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 makeAnswer and 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_MS and runPage unchanged).
  • Claim: the exit-first test fails with the old bare error when the outcome is decided on exit, as before #11590, and passes on close; the decision is #11590's: verified (mutation run; base render-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.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 14, 2026 00:39
@cixzhang
cixzhang merged commit fd9c379 into main Nov 14, 2026
180 of 182 checks passed
@github-actions
github-actions Bot deleted the fix/render-host-answer branch November 14, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — ef183725 Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant