feat(sdk): add Surfnet.stop() for graceful shutdown#642
Open
amilz wants to merge 3 commits intosolana-foundation:mainfrom
Open
feat(sdk): add Surfnet.stop() for graceful shutdown#642amilz wants to merge 3 commits intosolana-foundation:mainfrom
amilz wants to merge 3 commits intosolana-foundation:mainfrom
Conversation
Expose a JS-callable shutdown that closes the HTTP + WebSocket RPC servers and frees the bound port. Blocks until both servers acknowledge shutdown (via SimnetEvent::Shutdown) or the 5s timeout elapses; returns an error if shutdown is not confirmed so callers can treat it as fatal rather than silently leaking sockets. Use this from test teardown (e.g. afterAll) to avoid 'connection reset' / 'broken pipe' warnings caused by the OS yanking sockets at process exit. Drop still sends Terminate as a best-effort fallback when stop() was not called or failed. Closes DEV-467
Install a no-op log::Log on first surfnet boot so parity-ws skips its hardcoded println! fallback when a WS client closes uncleanly. parity-ws only ignores ECONNRESET when errno == 104 (Linux); on macOS ECONNRESET is 54, so the fallback fires on every client-side reset and pollutes stderr in test runners. Installing any logger makes log_enabled!(Error) return true, suppressing the println. Only mutates global log state when no logger is already registered, so host-installed loggers keep their configured max level.
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.
Summary
Surfnet::stop(&mut self)to the Rust SDK that sendsSimnetCommand::Terminateand blocks until both RPC servers (HTTP + WS) acknowledge shutdown viaSimnetEvent::Shutdown, with a 5s timeout.stop()through the napi binding and TypeScript wrapper so consumers can callsurfnet.stop()fromafterAlltest teardown.Dropkeeps its best-effortTerminatesend whenstop()was not called or failed.log::Logon first surfnet boot insdk-nodeto silence parity-ws's hardcodedprintln!fallback that fires on every client-side WS reset on macOS (parity-ws only ignores ECONNRESET whenerrno == 104(Linux); macOS ECONNRESET is 54). Only registers when no logger is already installed, leaving host-configured loggers untouched.Test Plan
cargo test -p surfpool-sdk -p surfpool-sdk-node— passes (22 + 0 tests).npm testincrates/sdk-node/— passes (6/6) including a new smoke test that callsstop()twice (idempotency on success), confirms the RPC fails after, and verifies the port is rebindable.cargo test --workspace— pre-existing flake insurfpool-coreunrelated to this change (verified by stashing the diff).sdk-nodeconsumers no longer seeEncountered an error: ... Enable a logger to see more information.on stderr during normal client disconnects on macOS.Closes DEV-467
(Replaces #641)