Repository navigation
fix(js): validate TCP.connect arguments before FFI setup - #1618
Merged
Lorenzobattistela merged 2 commits intoOct 16, 2026
Merged
Conversation
Lorenzobattistela
approved these changes
Oct 16, 2026
Merged
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 and fix
Malformed IPv4 addresses and out-of-range ports passed to
TCP.connectshould returnFail(22, ...). Emitted JS instead aborts on Node because it initializesbun:ffibefore validating those arguments.Move the existing
io_sys()declaration below the existing address guard, matchingTCP.listenandUDP.bind. Reuseio_addrandio_fail; no new fallback or exception handling.Blast radius
One statement moves in
bend2/effs/tcp_connect.js; two JS-specific regression files are added undertests/io. The compatibility change is limited to invalid arguments returning the declared failure instead of terminating when FFI is unavailable. Valid Node TCP remains unsupported. Valid Bun networking, descriptor ownership, native C, public signatures and the compiler are unchanged.Regression evidence
The new foreign twin makes FFI initialization throw once and restores the previous global property descriptor before throwing. The same test fails on main and passes with this fix in source execution and standalone JS under Bun and Node. Both shared
--checkuporders preserve subsequent networking tests.Ordinary programs without fault injection reproduce the Node failure for malformed IPv4, an oversized port and a NUL-containing host; each now prints
22. Bun/native results remain22before and after.Checks
git diff --checkpass.comp.ts.Validation limits
Local checks ran on macOS arm64 with Bun 1.3.11 and Node 26.8.2. The full IO suite and mini-cluster/Linux/GPU gates were not run. The regression exercises FFI absence in the Bun lane; it does not add a Node CI lane or support valid Node TCP.