feat(sdk): add Surfnet.stop() for graceful shutdown#641
Closed
amilz wants to merge 1 commit intosolana-foundation:mainfrom
Closed
feat(sdk): add Surfnet.stop() for graceful shutdown#641amilz wants to merge 1 commit intosolana-foundation:mainfrom
amilz wants to merge 1 commit 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
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.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).Closes DEV-467