Skip to content

fix(tests): keep boot logs off node:test stdout - #159

Open
tryingET wants to merge 1 commit into
agnt-gg:mainfrom
tryingET:fix/node-test-stdout
Open

tryingET wants to merge 1 commit into
agnt-gg:mainfrom
tryingET:fix/node-test-stdout

Conversation

@tryingET

Copy link
Copy Markdown
Contributor

Fixes #158.

What problem does this solve?

On Node 20.20.2, npm run test:node can fail a file at :1:1 with Unable to deserialize cloned data due to invalid or unsupported version. The stack is Node's test-runner parser. The named file is the worker whose stdout pipe carried the bytes, not a failed assertion.

node --test reads that pipe as V8 frames. A frame is FF 0F plus a 4-byte size. On Node 20.20.2 the size is a signed read. A UTF-8 lead byte spliced into that field makes readHeader() throw. Boot logs already do this on main. PathManager.js:76 logs 📁 AGNT root:. Line 74 logs AGNT data when the directories match, and line 77 logs AGNT data when they differ. database/index.js has 39 console.log calls that include a checkmark, including the column log at line 634. Those lines are non-ASCII.

How does it solve it?

npm run test:node now loads tests/setup/node-test-stdout.mjs with --import. That runs in the worker before the test file. It sends console.log and console.info to stderr. The runner reads stderr as text and does not deserialize it. --import is already forwarded to the worker, so no second hook is required.

The banner fixture is tests/fixtures/node-test-stdout-banner.js, not *.test.js. Vitest's default include would otherwise collect it, and vitest.config.js excludes tests/unit/** for that reason but not tests/fixtures/**.

Left alone on purpose:

How did you verify it?

Red, before the script imported the setup. node --test tests/unit/nodeTestStdout.test.js on Node 26.9.0:

AssertionError [ERR_ASSERTION]: The input did not match the regular expression /--import \.\/tests\/setup\/node-test-stdout\.mjs/. Input:

'node --test "tests/unit/**/*.test.js"'

Same tree, Node 20.20.2, node --test tests/fixtures/node-test-stdout-banner.js with no --import exited 1:

not ok 1 - tests/fixtures/node-test-stdout-banner.js
  error: 'Unable to deserialize cloned data due to invalid or unsupported version.'
  stack: |-
    #proccessRawBuffer (node:internal/test_runner/runner:358:20)
    FileTest.parseMessage (node:internal/test_runner/runner:294:28)
    Socket.<anonymous> (node:internal/test_runner/runner:393:15)

Green, after the change. node --test tests/unit/nodeTestStdout.test.js:

Node 26.9.0: tests 1, pass 1, fail 0, exit 0
Node 20.20.2: tests 1, pass 1, fail 0, exit 0

The same fixture with --import ./tests/setup/node-test-stdout.mjs on Node 20.20.2 exited 0: tests 4, pass 4, fail 0, and it did not print the deserialize error.

npm run test:node on Node 26.9.0 is not green on this machine either before or after. The new test passed inside that run. The other failures are the pre-existing provider, async-tool, and two file-level failures. Neither suite run printed the deserialize error. I did not run npm test or the frontend suite.

Checklist

  • This does not modify auth, sessions, or credential handling
  • This is not a fix for a security vulnerability
  • npm test passes
  • npm --prefix frontend test passes
  • New behaviour has tests, and I watched them fail before the fix
  • Docs updated if the surface changed
  • Commit subjects are 72 characters or fewer

- Node 20.20.2 reads each worker stdout pipe as V8 frames. A non-ASCII
  console.log can land in the length field and abort the file at :1:1.
- npm run test:node now imports a setup that sends console.log and
  console.info to stderr. Raw stdout writes are left alone.
- The new test failed on the unwired script, then passed on Node 20.20.2
  and Node 26.9.0. Without the import, the banner fixture still crashes
  Node 20.20.2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node 20.20.2 node:test crashes on non-ASCII startup logs, not the named test

1 participant