Skip to content

Fix flaky bundle verifier: stop parsing partial stdout lines - #15

Merged
HelloThisWorld merged 1 commit into
mainfrom
fix/bundle-verifier-partial-line
Aug 18, 2026
Merged

Fix flaky bundle verifier: stop parsing partial stdout lines#15
HelloThisWorld merged 1 commit into
mainfrom
fix/bundle-verifier-partial-line

Conversation

@HelloThisWorld

Copy link
Copy Markdown
Owner

Summary

The post-merge main run flaked on macOS/node 20 in "Verify the isolated plugin bundle" (failing job) with an uncaught non-JSON on stdout error right after a successful MCP handshake. The bundle is fine — the verifier script has a latent parsing race that v1.2 made much more likely to fire.

waitFor polls the accumulated stdout buffer every 50 ms and ran JSON.parse over every split('\n') segment — including the trailing partial line while a response is still streaming. tools/list grew to 50 tools in v1.2, a payload of hundreds of KB that always arrives across several pipe chunks; a poll landing between two data events saw an incomplete JSON fragment and rejected it as a stdout-purity violation. That is why the identical step passed on the PR run minutes earlier and on three of four platforms in the failing run: it is a timing race, and the larger payload widened the window.

The fix parses only complete lines (everything up to the last newline) and leaves an in-flight fragment for the next poll. A COMPLETE non-JSON line still fails hard, so the self-containment guarantee the check exists for is unchanged. pnpm verify:plugin-bundle passes locally (11/11).

Checklist

  • pnpm lint, pnpm typecheck, and pnpm test pass locally — script-only change; the verifier itself (pnpm verify:plugin-bundle) passes 11/11, and the full suites were green on this exact tree at the v1.2 merge
  • pnpm check:public-contracts passes — no contract touched
  • Documentation updated for any user-visible behavior change — none (CI script only)
  • CHANGELOG entry added for any user-visible change — none (no contract snapshot changed)
  • Everything is in English (code, comments, docs, commit messages)
  • No employer or client proprietary content — examples and fixtures are synthetic
  • No credentials, tokens, or secret values anywhere in the diff, fixtures, or recorded test output

The isolated-bundle MCP check polls the accumulated stdout buffer every
50 ms and ran JSON.parse over every split segment -- including the
trailing PARTIAL line while a response was still streaming. tools/list
grew to 50 tools in v1.2 (hundreds of KB, always split across several
pipe chunks), so a poll landing between two data events saw an incomplete
JSON fragment, called it "non-JSON on stdout", and flaked the mandatory
self-containment step on slow runners (post-merge main run, macOS
node 20; the identical step passed minutes earlier on the PR).

Only complete lines are protocol: the verifier now parses every line up
to the last newline and leaves an in-flight fragment for the next poll.
A COMPLETE non-JSON line still fails hard, so the stdout-purity guarantee
is unchanged.
@HelloThisWorld
HelloThisWorld merged commit 5cfc03d into main Aug 18, 2026
7 checks passed
@HelloThisWorld
HelloThisWorld deleted the fix/bundle-verifier-partial-line branch August 18, 2026 14:59
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.

1 participant