rpc: exit JS server when parent connection closes#7652
Merged
Conversation
When the host JVM is SIGKILLed, its shutdown hook never fires, so RewriteRpcProcess.shutdown() doesn't call process.destroy() on the JS subprocess. The Python and Go servers self-terminate on stdin EOF; C# exits when JsonRpc.Completion resolves. But the JS server's connection.onClose handler only logged — and Pyroscope (or any other ref-holder) kept the Node event loop alive, orphaning the process. Wire connection.onClose to a shared shutdown() that also runs on SIGINT/SIGTERM, so all three exit paths converge on the same cleanup (recipe temp dir + DependencyWorkspace) and exit with code 0.
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
RewriteRpcProcess.shutdown()never invokesprocess.destroy()on spawned RPC subprocesses. The Python (stdin EOF → break), Go (io.EOF→ break), and C# (JsonRpc.Completion) servers all exit naturally in that case; the JS server did not, becauseconnection.onCloseonly logged — and Pyroscope (or any other event-loop ref-holder) kept the Node process alive, orphaning it on the host.connection.onCloseon a singleshutdown()(with a re-entry guard) that performs temp-dir + workspace cleanup and exits with code 0. This closes the orphan-on-parent-SIGKILL hazard while keeping the existing signal-handler cleanup behavior.Test plan
npm run typecheckpasses