Skip to content

Stop counting macOS setTypeOfService EINVAL as a test failure - #389

Merged
Brooooooklyn merged 1 commit into
mainfrom
fix/node-target-settypeofservice
Oct 8, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
fix/node-target-settypeofservice

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Problem

Full-suite runs on macOS sometimes end with one unhandled error, setTypeOfService EINVAL, blamed on node-target.test.ts. All tests pass, but Vitest counts the error, so the run fails.

test worker (Node 24, macOS)              vp dev (Vite)
----------------------------              -------------
waitForServer: fetch 127.0.0.1:P   --->   port check: listen 0.0.0.0:P, then close
  handshake done, still queued            close() resets the queued connection (RST)
  'connect' callback runs
  undici 7: socket.setTypeOfService(0)
  setsockopt(IP_TOS) -> EINVAL
  throws inside the event handler
    -> uncaught -> Vitest "1 error" -> run fails
  (the fetch itself rejects with ECONNRESET and waitForServer retries)

Fix

Add a root test.onUnhandledError filter that drops only errors with syscall: 'setTypeOfService' and code: 'EINVAL'. This does the same thing as the upstream fix: it treats the failed call as best-effort. The fetch still rejects, so callers see the failure as before. Other unhandled errors are still reported.

We can remove the filter once Node 24 ships an undici with the fix.

Testing

Check Before After
Test that forces a reset (10 runs) 10/10 runs fail 0/10 fail, 12 errors dropped
node-target.test.ts with fast polling to widen the race (25 runs) 6/25 fail with this exact error 0/25 fail, 4 errors dropped
node-target.test.ts as-is: 20 runs idle, 40 under CPU load 0/60 (race is rare at 200 ms polling) -
Real vp dev startup with tight fetch polling (30 starts) 7 uncaught EINVAL -
Control: built Node server, same polling (30 starts) 0 -
Unrelated uncaught error reported still reported
Linux (Docker, Node 24.21.0), reset socket setsockopt returns 0 -
vp lint, vp fmt --check, node-target.test.ts - pass
vp test run (full suite, macOS) - pass: 688 files passed, 1 skipped; 13062 tests passed, 29 skipped

🤖 Generated with Claude Code

Node 24 bundles undici 7, whose fetch sets the socket type of service on
each new connection without catching errors. On macOS this throws EINVAL
when Vite's dev-server port check resets a polling connection, and it
escapes as uncaught. The fetch still rejects, so only the stray copy is dropped.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T03:56:24.612677Z 2237cfc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-node-target-settypeofservice-void-cloud.voidzero-docs.workers.dev (commit 2237cfc)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://3898f50e-void-cloud.voidzero-docs.workers.dev 2237cfc 2026-10-08T03:55:56.364Z Visit the dashboard ↗

@Brooooooklyn
Brooooooklyn merged commit 7ad0804 into main Oct 8, 2026
20 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/node-target-settypeofservice branch October 8, 2026 04:32
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