fix(cli): ensure sandbox proxy cleanup and remove handler leaks#26065
fix(cli): ensure sandbox proxy cleanup and remove handler leaks#26065
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves the reliability of the sandbox session management by ensuring that proxy processes and containers are consistently terminated. By centralizing the cleanup logic and explicitly managing event listeners, the changes prevent resource leaks and potential process crashes during sandbox teardown. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
Size Change: +76 B (0%) Total Size: 33.8 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request improves the lifecycle management of the sandbox proxy by ensuring exit handlers are properly registered and cleaned up. It introduces a finally block in start_sandbox to invoke the proxy shutdown and remove signal listeners. Additionally, error handling was added to the proxy termination logic to prevent cleanup failures from crashing the process. A new test case was added to verify the registration and unregistration of these handlers. A security concern was raised regarding the use of execSync with potentially unsanitized input, which could lead to command injection; switching to spawnSync was suggested.
Summary
Ensures that sandbox proxy processes and containers are consistently cleaned up when the sandbox session ends. This PR refactors the
stopProxylogic into afinallyblock and removes event handlers to prevent leaks.Details
stopProxyto be scoped to thestart_sandboxfunction and invoked in thefinallyblock for guaranteed cleanup.process.offforexit,SIGINT, andSIGTERM.try-catchblocks to prevent cleanup failures from crashing the main process.packages/cli/src/utils/sandbox.test.tsto verify that handlers are correctly registered and unregistered.Related Issues
Fixes #24334
How to Validate
Run the targeted test:
npm test packages/cli/src/utils/sandbox.test.tsPre-Merge Checklist