Repository navigation
Conversation
…'s stdout node --test runs each file in a child that reports its results as framed messages on that child's stdout. On Node 22 (and 24), when a file's own stdout text arrives in the same read as one of those messages, the runner reads bytes 2-5 of the text as the next frame's length. A non-ASCII byte there (the emoji in "🔐 secret 'ZZ_DBG' set (…)") makes the length negative, the text goes to the deserializer, and the whole file fails with "Unable to deserialize cloned data due to invalid or unsupported version." Node fixed the parser upstream (nodejs/node#66273); 22.x does not have it. The secret CLI test "restores a secret that remove scheduled for deletion, then sets it" let runValueCli print its result there. It now captures it, as the file's other store tests do, and checks that the restore is reported. The same pattern, in tests that pass today only because their output comes before the runner's first message: - Next.js, Nuxt and SvelteKit adapter tests that reach the adapters' stdout progress lines ("🔗 Detected …", "🚀 Lifted …") mute stdout around the synchronous adapter call. - A SvelteKit bridge-guard test ran a real `npm run build` with inherited stdio. The build is now stubbed to fail, as it did without a toolchain. - The cdk-blocks help-safety tests that run the real secret and config CLIs through to a store call capture their console.log, like the file's help tests.
🦋 Changeset detectedLatest commit: 0ec7a73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This was referenced Nov 11, 2026
Merged
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
packages/hostingunit tests sometimes fail a whole file in under a second, and pass on rerun:Just before it, the log shows the CLI's own output:
♻️ secret 'ZZ_DBG' was scheduled for deletion; restored it.and🔐 secret 'ZZ_DBG' set (blocks/secrets/ZZ_DBG).Cause.
node --testruns each file in a child that sends its results to the parent as framed messages (FF 0F, a 4-byte length, a v8-serialized value) on the child's stdout. Other text the file writes to stdout shares that pipe. On Node 22 (CI runs 22.23.4) and 24, after a complete frame#processRawBufferreads bytes 2–5 of whatever follows as the next frame's length, without checking for the header. When the test's own text arrives in the same read as the frame before it, those bytes come from the text. In♻️(e2 99 bb ef b8 8f) the length is0xbbefb88f, a negative int32. The parser then thinks it already holds the whole frame, gives the text to the deserializer, andreadHeader()throws. The text never goes inside a frame: a capture of the child's stdout has 218 intact frames plus exactly one non-frame range, those two lines. Whether the text and the frame share a read depends on timing, so the failure is a flake that load makes more likely. Node fixed the parser on main in nodejs/node#66273 (issue nodejs/node#66164). 22.x does not have the fix.The test that writes those lines is
runValueCli() — Secrets Manager edge cases › restores a secret that remove scheduled for deletion, then sets it. It letssetValue'sconsole.logreach the real stdout. The CLI is right to print its result to stdout. The test is not right to let it reach the runner's channel.Changes
Tests only. They no longer let the code under test write to the test process's stdout:
packages/hosting/src/secret-cli.test.ts: the restore test capturesconsole.logwithmock.method, as the file's other store tests do, and checks that the restore is reported.packages/hosting/src/adapters/{nextjs,nitro,sveltekit}.test.ts: 10 tests reach the adapters' stdout progress lines (🔗 Detected … basePath/baseURL/paths.base/assetPrefix,🚀 Lifted N redirect(s)…). They now muteprocess.stdout.writeonly around the synchronous adapter call. Nothing else can write during a synchronous call, so the runner's frames are never swallowed. These files pass today only because the output comes before the runner's first frame, which the parser handles. Any earlier async test would move it after a frame.sveltekit.test.ts,does NOT throw when the only adapter reference is a commented-out incompatible adapter: this test ran a realnpm run buildwithstdio: 'inherit', so a second process wrote straight to the runner's pipe. The build is now stubbed (t.mock.method(spawn, 'sync', …)) to fail, as it did without a toolchain. The assertion that the error is not the incompatible-adapter error is unchanged.packages/blocks/src/cli/help-safety.test.ts: the two tests that run the real secret and config CLIs through to a store call printed🗑️ … removedafter frames, the same crash shape as the secret CLI test. They now captureconsole.logthrough a small helper, which the file's existing--helpcapture also uses now.The adapters' stdout lines and the value CLI's
console.logresults are unchanged. Thecdk-blocksCLI routes child-tool output to stderr in--output jsonmode, andsecret/confighave no JSON mode, so neither breaks a machine-readable stdout contract.Validation
Node 22.23.1 locally, the closest available to CI's 22.23.4.
#processRawBufferis the same in both.Deterministic reproduction. I captured the child stream (
NODE_TEST_CONTEXT=child-v8 node dist/secret-cli.test.js) and replayed it with onewriteSync(1, …)from a file run undernode --test. Before the fix this gives the exact CI error. The same bytes in two reads, split before the stray text, pass. ASCII-only stray text after a frame passes. After the fix the capture has 218 frames and no other bytes, and the replay passes.Loop, 300 ×
node --test dist/secret-cli.test.jsfrompackages/hosting:Every failure before the fix was
Unable to deserialize cloned data ….Audit. I ran every
packages/hostingtest file (76),packages/blocks/dist/cli/*.test.js(9) and the core secret/config tests (3) aschild-v8children and listed the stdout bytes that are not frames. Before the fix: secret-cli, nextjs, nitro, sveltekit and help-safety. After the fix: none.npm run build && npm run lint && npm run lint:deps && npm test && npm run test:e2e:localon Node 22.23.1 with AWS credentials unset all passed. Unit: 44 workspace runs, 8775 tests, 0 failed, 7 skipped. e2e (local): 4 suites, 426 tests, 0 failed, 4 skipped.Changed files alone: hosting secret-cli + nextjs/nitro/sveltekit adapters 261/261, blocks
cli/help-safety16/16.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.