Remove unnecessary try/catch guards in NODERAWSOCKETS backend#27351
Open
guybedford wants to merge 1 commit into
Open
Remove unnecessary try/catch guards in NODERAWSOCKETS backend#27351guybedford wants to merge 1 commit into
guybedford wants to merge 1 commit into
Conversation
The node raw sockets backend wrapped many public net.Socket/net.Server stream methods (pause/resume/destroy/end/setNoDelay/setKeepAlive, server close, dgram disconnect) in try/catch even though none of them throw in the states they are called on Node 18+. Drop those guards, keeping only the catches that translate a genuine Node throw into a POSIX errno or guard a private/capability API. Also fix out-of-range UDP setsockopt values (e.g. IP_MULTICAST_TTL=300) to return EINVAL instead of being silently swallowed, handling both the public dgram (throws) and udp_wrap (negative libuv code) paths, and dropping the rejected value so it neither takes effect nor re-fails a later replay. Collapse the redundant v4/v6 multicast option keys: IP_MULTICAST_TTL and IPV6_MULTICAST_HOPS (and likewise the two *_MULTICAST_LOOP options) map to the same family-agnostic libuv setter, so they share one cached value each.
sbc100
reviewed
Jul 14, 2026
sbc100
approved these changes
Jul 14, 2026
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.
This trims the try/catch guards in the
-sNODERAWSOCKETSbackend down to those that are actually needed on Node 18+.Most of the removed guards wrapped public
net.Socket/net.Serverstream methods (pause/resume/destroy/end/setNoDelay/setKeepAlive, server close, dgram disconnect) that never throw in the states they are called. The remaining catches all serve a real purpose: translating a Node throw into a POSIX errno, guarding a private (process.binding) or capability API, or handling a dgram double-close.While here, out-of-range UDP
setsockoptvalues (e.g.IP_MULTICAST_TTL=300) now returnEINVALinstead of being silently swallowed. Both the public dgram path (throws) and the udp_wrap fallback path (negative libuv code) are handled, and a rejected value is dropped so it neither takes effect nor re-fails a later option replay.test_udp_sockopts.c is extended: an out-of-range set now asserts EINVAL and a subsequent valid set still succeeds.
Made with AI assistance, under my review.