Repository navigation
fix(cli): preserve theme microtask error context on Node 22.13 - #12032
astracat-bot[bot] wants to merge 3 commits into
Conversation
|
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.
Changes requested: the loader fix is sound, but the release note credits the wrong contributor.
- Replace
@codebunnyon line 6 of.changeset/cli-theme-microtask-context.mdwith the account or person that authored this change (@astracat-bot, as the changeset in #11186 does), because the changelog publishes that line as the contributor credit.
The queueMicrotask fallback restores ERR_THEME_LOAD with the theme path on Node 22.13: the new tests and the N37 regression fail on the base and pass on the head on that version, and Node 24 behaves as before. Optionally, the changeset could also say that, on Node 22.13, a microtask callback that throws after the theme loads is now a warning instead of a failed build.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: on Node 22.13 a theme that throws from a queued microtask while loading answered
ERR_UNKNOWN— verified: the N37 test and the new tests fail on the base on Node 22.13.0, as in the failing minimum-Node CI run. - Claim: Node 22.13 reports the exception after restoring the async context, and Node 24 keeps it — verified with a plain Node check on 22.13.0 and 24.20.0.
- Claim: the origin is recorded only when a guarded callback throws, and the original value is rethrown — verified,
module-loader.mjs:564-577. - Claim: the classifier consumes the record, and a later microtask clears an unused one — verified,
module-loader.mjs:574and:584-585. - Claim: calls outside guarded loads and native argument validation are unchanged — verified,
module-loader.mjs:566and the native-validation test. - Claim: no timeout, assertion, public API, Node floor or stylesheet-loader change — verified from the diff; an API surface comparison shows no changed rows and the published themes build identical CSS.
- Claim: the regression cases cover Error and string throws, late warnings, an unrelated throw during a load, and native validation — verified in
module-loader.microtasks.test.mjs. - Claim: the wider loader suites pass on the pinned Node — verified on Node 24.20.0; on Node 22.13.0, three stylesheet cases in
build-stable-hunt241L.test.mjsfail on base and head alike. - Claim: there is no Node version check — verified.
- Claim: lint, formatting, the changeset check, the CLI structure check and the strict typecheck pass — verified on the head.
- Changeset:
theme buildreports a loading theme's microtask exception asERR_THEME_LOADon Node 22.13 with the theme path and the original error — verified by N37 on Node 22.13.0. - Changeset: late theme callbacks remain warnings — true at the head, but on Node 22.13 a late microtask throw used to fail the build, so the wording understates the change.
- Changeset: unrelated exceptions keep their own error boundary — verified by the unrelated-exception test.
- Changeset: contributor
@codebunny— false; the change was authored byastracat-bot. - File
.changeset/cli-theme-microtask-context.md: the blocking contributor finding and the optional wording note. - File
packages/cli/foundation/fs/module-loader.mjs: clear. - File
packages/cli/foundation/fs/module-loader.microtasks.test.mjs: clear.
|
validation: not run: this follow-up changes only the contributor-credit line. Verified the one-line diff and checked the credited account against the reviewed commit's author; no runtime or test changes. Addressed the blocking review finding by replacing The reviewed commit is authored by
|
There was a problem hiding this comment.
Changes requested: the Node 22.13 fix works for a theme whose folder has its own Core, but the release note promises more than the change delivers.
- Miss:
.changeset/cli-theme-microtask-context.mdline 5 says a loading theme's microtask exception is reported asERR_THEME_LOADon Node 22.13, but a standalone theme with no Core of its own still builds with exit 0 and the exception dropped, because its synchronous load wins the race inwithThemeModuleGuards(module-loader.mjs:720-724), so either make the recorded failure win that race and add a test whose load returns without awaiting, or narrow the sentence to themes whose folder has its own Core.
The contributor credit is fixed. The standalone path already drops the exception on Node 24, so the race is shared code rather than something this change introduced there. Optionally, the changeset could also say that on Node 22.13 a microtask callback that throws after the theme loads is now a warning instead of a failed build.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim: on Node 22.13 a theme that throws from a queued microtask while loading answered
ERR_UNKNOWN— verified: the N37 test and the new tests fail on the base on Node 22.13.0, as in the failing minimum-Node CI run. - Claim: Node 22.13 reports the exception after restoring the async context, and Node 24 keeps it — verified with a plain Node check on 22.13.0 and 24.20.0.
- Claim: the origin is recorded only when a guarded callback throws, and the original value is rethrown — verified,
module-loader.mjs:564-577. - Claim: the classifier consumes the record, and a later microtask clears an unused one — verified,
module-loader.mjs:574and:584-585. - Claim: calls outside guarded loads and native argument validation are unchanged — verified,
module-loader.mjs:566and the native-validation test. - Claim: no timeout, assertion, public API, Node floor or stylesheet-loader change — verified from the diff; an API surface comparison shows no changed rows and the published themes build identical CSS.
- Claim: this restores the load refusal on the minimum supported runtime — partly false: restored when the theme's folder has its own Core; a standalone theme builds with the exception dropped.
- Claim: the regression cases cover Error and string throws, late warnings, an unrelated throw during a load, and native validation — verified in
module-loader.microtasks.test.mjs; each case awaits before its load returns. - Claim: the wider loader suites pass on the pinned Node — verified on Node 24.20.0.
- Claim: there is no Node version check — verified.
- Claim: lint, formatting, the changeset check, the CLI structure check and the strict typecheck pass — verified on the head.
- Changeset:
theme buildreports a loading theme's microtask exception asERR_THEME_LOADon Node 22.13 with the theme path and the original error — false for a standalone theme; verified for a theme whose folder has its own Core. - Changeset: late theme callbacks remain warnings — true at the head, but on Node 22.13 a late microtask throw used to fail the build, so the wording understates the change.
- Changeset: unrelated exceptions keep their own error boundary — verified by the unrelated-exception test.
- Changeset: contributor
@astracat-bot— verified; it is the commits' author. - File
.changeset/cli-theme-microtask-context.md: the blocking scope finding on line 5 and the optional wording note. - File
packages/cli/foundation/fs/module-loader.mjs: the fallback is correct; the refusal race it relies on is the blocking finding's cause. - File
packages/cli/foundation/fs/module-loader.microtasks.test.mjs: clear.
|
validation: not run: the repository's test runner was not rerun for this documentation-only follow-up; the implementation and tests are unchanged. Address the requested release-note correction by narrowing the loading-time The PR description uses the same scope and explicitly records that the existing standalone synchronous-load race is not fixed. This chooses the reviewer's minimal wording correction rather than expanding shared loader behavior. No implementation or test files changed, and no tests were re-investigated on the default branch. |
There was a problem hiding this comment.
Changes requested: the Node 22.13 fix works for a single theme whose folder has its own Core, but the narrowed release note still covers --family builds, which drop the exception.
- Miss:
.changeset/cli-theme-microtask-context.mdline 5 promisesERR_THEME_LOADon Node 22.13 for any loading theme whose folder has its own Core, but a--familybuild of such themes always loads through Core interception's synchronous path and now exits 0 with the exception dropped (the base answeredERR_UNKNOWN), so either say "a single theme whose folder has its own Core" and match the description's scope paragraph, or make the recorded failure win the race inwithThemeModuleGuards(module-loader.mjs:720-724) and add a test whose load returns without awaiting.
Sorry for the extra round: the wording suggested in the previous review missed the --family path. The late-warning sentence and the exclusion of themes without their own Core are now accurate. A project whose selected Core does not generate adaptation CSS appears to take the same synchronous path (build.mjs:3170), so the race fix is the change that makes the original sentence true everywhere.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim: this follow-up changes only the release note, and the implementation and tests are unchanged — verified: line 5 of the changeset is the only change since the previous head.
- Claim: the changeset check, Prettier on the changeset, the pre-review report and the whitespace check pass — verified on the head (552 valid changesets, formatted, no findings, clean).
- Claim: on Node 22.13, a theme whose folder has its own Core and throws from a queued microtask while loading answered
ERR_UNKNOWN— verified: the base answersERR_UNKNOWNon Node 22.13.0 on every load path. - Claim: Node 22.13 reports the exception after restoring the async context, and Node 24 keeps it — verified with a plain Node check on 22.13.0 and 24.20.0.
- Claim: the origin is recorded only when a guarded callback throws, and the original value is rethrown — verified,
module-loader.mjs:564-577. - Claim: the classifier consumes the record, and a later microtask clears an unused one — verified,
module-loader.mjs:574and:584-585. - Claim: calls outside guarded loads and native argument validation are unchanged — verified,
module-loader.mjs:566and the native-validation test. - Claim: no timeout, assertion, public API, Node floor or stylesheet-loader change — verified from the diff; an API surface comparison shows no changed rows and the published themes build identical CSS.
- Claim: this restores the N37 case on the minimum runtime when the theme's folder has its own Core — verified for a single-theme build: N37 fails on the base and passes on the head on Node 22.13.0.
- Claim: the standalone race for a theme without its own Core is left unfixed and drops the exception on both runtimes — true but incomplete:
--familybuilds take the same synchronous path. - Claim: the release note is narrowed to the case this change fixes — false: it still covers
--familybuilds. - Claim: on Node 22.13, a microtask callback that throws after its load now produces a warning instead of failing the build — verified: the base fails with
ERR_UNKNOWN, the head warns and exits 0. - Claim: the cited minimum-Node CI failure ran at the base commit — verified from the run and job metadata.
- Claim: N37 failed before, and the F42 file and the focused cases pass after on Node 22.13 — verified (base N37 fails; head 9 of 9 pass).
- Claim: the regression cases cover Error and string throws, late warnings, an unrelated throw during a load and native validation, and each awaits before returning — verified in
module-loader.microtasks.test.mjs. - Claim: the wider loader suites pass on the pinned Node — verified on Node 24.20.0 (71 passed, 1 skipped).
- Claim: there is no Node version check — verified.
- Claim: lint, formatting, the changeset check, the CLI structure check and the strict typecheck pass — verified on the head.
- Changeset: on Node 22.13,
theme buildreports a microtask exception from a loading theme whose folder has its own Core asERR_THEME_LOAD, with the theme path and the original error — false for--familybuilds; verified for a single-theme build. - Changeset: a theme microtask callback that throws after the load now produces a warning instead of failing the build — verified on Node 22.13.
- Changeset: unrelated exceptions keep their own error boundary — verified by the unrelated-exception test.
- Changeset: contributor
@astracat-bot— verified; it is the commits' author. - File
.changeset/cli-theme-microtask-context.md: the blocking scope finding on line 5. - File
packages/cli/foundation/fs/module-loader.mjs: the fallback is correct; the refusal race it relies on is the blocking finding's cause. - File
packages/cli/foundation/fs/module-loader.microtasks.test.mjs: clear.
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [fix] On Node 22.13, `astryx theme build` reports a microtask exception from a loading theme whose folder has its own Core as `ERR_THEME_LOAD`, with the theme path and the original error. A theme microtask callback that throws after the load now produces a warning instead of failing the build. Unrelated exceptions keep their own error boundary. |
There was a problem hiding this comment.
Miss: this sentence still covers --family builds, and they drop the exception. A family build always loads its members through Core interception (api/theme/build/build.mjs:4760-4761, :6437-6458), which takes the synchronous jiti(filePath) load (:2875). That load settles before load.fail can reject the race in withThemeModuleGuards (module-loader.mjs:720-724). On Node 22.13, a family (ocean + ocean-calm, folder with its own Core) whose member throws from a microtask while it loads answered ERR_UNKNOWN on the base; with this change it builds with exit 0 and nothing on stderr. A single-theme build of the same member answers ERR_THEME_LOAD. The wording suggested in the previous review missed this path.
Either make the recorded failure win the race (for example, fail stores the error on the load and the guard rethrows it after the race) and add a case whose load returns without awaiting, or narrow the sentence, for example:
[fix] On Node 22.13, `astryx theme build` of a single theme whose folder has its own Core reports a microtask exception from the loading theme as `ERR_THEME_LOAD`, with the theme path and the original error.
validation: not run: the repository's test runner was not rerun for this documentation-only follow-up; the implementation and tests are unchanged.
pnpm check:changesetspassed (552 valid);pnpm exec prettier --check .changeset/cli-theme-microtask-context.mdpassed;pnpm review:pre --jsonreported no findings;git diff --checkpassed. Prior implementation validation is recorded below.User impact
On the supported minimum Node version, a theme whose folder has its own Core and that throws from a queued microtask while loading answers
--jsonwithERR_UNKNOWN, rather than the theme-load refusal and source path. Consumers cannot identify that failed theme load from its stable error code.Cause and smallest restoration
Node 22.13 reports a
queueMicrotaskexception after restoring its AsyncLocalStorage context. The existing exception classifier therefore cannot find the guarded load. Node 24.22.1 retains that context.Record the originating load only when a guarded microtask callback throws, then rethrow the original value through the existing exception boundary. The classifier consumes the record; a following microtask clears an unused record. Calls outside guarded loads and native callback validation remain unchanged. No timeout, assertion, public API, Node compatibility floor, or stylesheet-loader behavior changes.
Expected behavior and authority
architecture:cli-surfaceINV2 and INV3 preserve the single error envelope and stable code meanings.ERR_THEME_LOADmeans a theme file could not load or parse. The existing N37 regression in #11937 explicitly requires a microtask throw during loading to refuse that load; this restores that case on the minimum supported runtime when the theme's folder has its own Core.This does not fix the existing standalone-theme race: when the theme's folder has no Core of its own, its synchronous load can win the guarded-load race and drop the microtask exception on both Node 22.13 and Node 24. The release note is narrowed to the case this change fixes. On Node 22.13, a theme microtask callback that throws after its load now produces a warning instead of failing the build.
Evidence
cli-minimum-node.yml, run 43825339875, job 133157785259, commit0f4c0aa4850ea527b91cc82ccc259b054bd1b303.ERR_THEME_LOAD, receivedERR_UNKNOWN. After recording the reproduction and fetching current main, it failed another 2/2 runs at the same commit.The fallback applies on both tested Node versions instead of relying on a version-number check. The full repository suite was not run.
Prior implementation validation
Ran
pnpm exec vitest run packages/cli/api/theme/build/build-stable-L-final42.test.mjs packages/cli/foundation/fs/module-loader.microtasks.test.mjs --project nodetwice on Node 22.13.0 (9/9 passed each); ranpnpm exec vitest run packages/cli/foundation/fs/module-loader packages/cli/api/theme/build/build-stable-L-final42.test.mjs packages/cli/api/theme/build/build-stable-hunt241L.test.mjs --project nodeon Node 24.22.1 (71 passed, 1 skipped). Targeted strict ESLint, Prettier,pnpm check:changesets, andpnpm check:cli-structurepassed.pnpm -F @astryxdesign/theme-neutral buildand thenpnpm -F @astryxdesign/cli typecheck:strictpassed.Review follow-up
Narrow the changeset and matching description claims to themes whose folder has its own Core, and make the Node 22.13 late-microtask warning change explicit. No behavior change in this follow-up; no implementation or test files changed. The broader standalone race is intentionally left unchanged rather than expanding this compatibility fix.
Failing test fixed
a3853608afff4c78618397d631b4d70b0c221a4f5a1a6ccc0e0a35923e617ffbpackages/cli/api/theme/build/build-stable-L-final42.test.mjs › chaos N37: a theme module that throws from a microtask while it loads › is a refused load naming the error, never exit 7, a stack or ERR_UNKNOWN