fix(sidecar): release kernel socket slots when guest sockets close#196
Merged
NathanFlurry merged 1 commit intoJul 2, 2026
Conversation
Closed guest loopback sockets never released their kernel socket-table slots until process exit (measured: vm_sockets highWater 81 for a workload whose true concurrency is ~9), so connection-churning guests hit EAGAIN 'maximum socket count reached' at ~250 cumulative sockets. - Bridge: natural FIN close finalization now releases the sidecar/kernel handle (idempotent, once), deferred until JS readable buffers drain so buffered data is never dropped. - Sidecar: net.poll close handling closes the underlying TCP/Unix handle when removing map entries; explicit close paths funnel through an idempotent kernel close (ENOENT tolerated); the TLS-mode close path no longer skips kernel close for kernel-backed sockets. - Guest fetch() now uses a bounded per-call undici dispatcher instead of the process singleton whose pooled clients went stale against released sockets and hung (also fixes a pre-existing hang: repeated fetch over a kept-alive loopback connection). Revisit pooling when host->guest socket event push (#178) lands. - Regression test: guest churns 3x max_sockets connections with closes. Full net family at 30 iterations passes (previously EAGAIN at tcp_concurrent_4): fetch 2.59ms, tcp_echo 3.57ms, tcp_concurrent_4 4.91ms guest p50; leak probe highWater 81 -> 17 with depth returning to 0.
Member
Author
|
Stack for rivet-dev/secure-exec
Get stack: |
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.
Closed guest loopback sockets never released their kernel socket-table slots
until process exit (measured: vm_sockets highWater 81 for a workload whose
true concurrency is ~9), so connection-churning guests hit EAGAIN 'maximum
socket count reached' at ~250 cumulative sockets.
handle (idempotent, once), deferred until JS readable buffers drain so
buffered data is never dropped.
removing map entries; explicit close paths funnel through an idempotent
kernel close (ENOENT tolerated); the TLS-mode close path no longer skips
kernel close for kernel-backed sockets.
process singleton whose pooled clients went stale against released sockets
and hung (also fixes a pre-existing hang: repeated fetch over a kept-alive
loopback connection). Revisit pooling when host->guest socket event push
(perf: push socket events host→guest instead of guest wait=0 polling #178) lands.
Full net family at 30 iterations passes (previously EAGAIN at tcp_concurrent_4):
fetch 2.59ms, tcp_echo 3.57ms, tcp_concurrent_4 4.91ms guest p50; leak probe
highWater 81 -> 17 with depth returning to 0.