Repository navigation
chore(sdk): share process kill between commands and PTY, share CLI --language parser, drop unused internal exports - #1993
Conversation
…language parser, drop unused internal exports Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
🦋 Changeset detectedLatest commit: 968edec The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
TASTE.md review: no violations found in the changed code — parity (T-1, T-1a, T-2), signal threading via getSignal (T-46), kill returning false on NotFound (T-32/T-60) and docstrings (T-69–T-71) checked; the shared killProcess / kill_process / akill_process helpers are internal and keep the public surface unchanged.
| export async function killProcess( | ||
| rpc: Client<typeof ProcessService>, | ||
| pid: number, | ||
| signal: AbortSignal | undefined, | ||
| checkHealth: SandboxHealthCheck | ||
| ): Promise<boolean> { |
There was a problem hiding this comment.
🟡 Shared kill paths lack regression coverage
When killProcess replaces both kill implementations, no tests are created or updated for its error paths. Existing kill tests cover success and missing processes, leaving transport failures untested.
Learn more
The repository requires creating or updating tests for affected codepaths. This PR adds shared kill helpers in killProcess, kill_process, and akill_process without changing any tests. Existing kill integration tests cover ordinary success and missing PIDs, but do not cover failures handled by the helpers.
Example: If sendSignal rejects with a transport failure, the helper must preserve the health-check mapping; no new or updated test asserts that behavior.
Recommended fix: Add focused tests for the shared helpers' success, not-found, and health-check failure branches in JS and both Python modes. Update CLI tests for the extracted parseLanguage parser, then run the affected tests.
Was this helpful? React with 👍 or 👎 to provide feedback.
Package ArtifactsBuilt from 8582191. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-dockerfile-utils-0.1.2-devin-1792393434-sdk-dead-code.0.tgz ./e2b-2.56.1-devin-1792393434-sdk-dead-code.0.tgzCLI ( npm install ./e2b-cli-2.22.1-devin-1792393434-sdk-dead-code.0.tgzCode Interpreter JS SDK ( npm install ./e2b-code-interpreter-2.9.1-devin-1792393434-sdk-dead-code.0.tgzDesktop JS SDK ( npm install ./e2b-desktop-2.5.1-devin-1792393434-sdk-dead-code.0.tgzPython SDK ( pip install ./e2b_dockerfile_utils-0.1.1+devin.1792393434.sdk.dead.code-py3-none-any.whl ./e2b-2.56.0+devin.1792393434.sdk.dead.code-py3-none-any.whlCode Interpreter Python SDK ( pip install ./e2b_code_interpreter-2.11.0+devin.1792393434.sdk.dead.code-py3-none-any.whlDesktop Python SDK ( pip install ./e2b_desktop-2.7.0+devin.1792393434.sdk.dead.code-py3-none-any.whl |
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. The refactor looks behavior-preserving, but the repo's CODEOWNERS file covers every path, so a code owner should still sign off.
What was reviewed:
- JS
killProcessand Pythonkill_process/akill_process: they send the same SIGKILL request, return false on NotFound, and route other errors through the health-check handlers. The signal and timeout values reach the RPC exactly as they did before. - The new imports don't create a cycle.
e2b.envd.utils,process_pbandprocess_connectdon't importe2b.envd.rpc, and in the JS SDKprocess_pbdoesn't importenvd/rpc. - The un-exported helpers (
isFetchTransportFailure,getEnvdApiErrorMessage,formatSandboxUnreachableError) are only referenced in their own modules.parseLanguagekeeps the same validation and error message.
Extended reasoning...
The change moves duplicated SIGKILL logic in the JS SDK and both Python SDKs (sync and async) into shared helpers. It also shares the CLI --language parser and stops exporting three internal JS helpers. It touches no auth, crypto or data-exposure code. The code matches the old inline logic, and I found no import cycles or remaining external uses of the removed exports. I deferred because CODEOWNERS assigns the whole repository to one owner, which rules out an automatic approval.
Summary
A mechanical de-duplication and dead-export cleanup across the SDKs and CLI. Behavior and public API stay the same.
Removed / de-duplicated
Commands.killandPty.killhad the sameSendSignal(SIGKILL)body, withNotFound → falseand health-check error mapping. Both now delegate to one shared helper:killProcess(rpc, pid, signal, checkHealth)inpackages/js-sdk/src/envd/rpc.tskill_process/akill_processinpackages/python-sdk/e2b/envd/rpc.py, which follow the existinghandle_rpc_exception_with_health/ahandle_…pairingCode/ConnectError/Signalimports that are no longer used.--languageoption parser: the same validator was inlined intemplate initandtemplate migrate. It is now one sharedparseLanguageincommands/template/generators/types.ts, with the same error message.src/index.ts, so they are no longer exported (un-exported, not deleted):isFetchTransportFailureandgetEnvdApiErrorMessage(envd/api.ts)formatSandboxUnreachableError(envd/rpc.ts)I grepped the whole monorepo (tests, examples, other packages) for each symbol before changing it.
Public-API candidates deliberately left in place
Sandbox.create(secure=…)/AsyncSandbox.create(secure=…): the parameter is ignored but documented as deprecated. Removing it is a breaking change.VolumeMetadataOptions/VolumeWriteOptions: deprecated aliases exported from the entry point for backwards compatibility.ConnectionConfig.validateApiKeyandConnectionConfig.envdPort: unused inside the SDK, but they are public members of an exported class.src/index.ts:PtyCreateOpts,PtyConnectOpts,SandboxUrlOpts,FilesystemListOpts,FilesystemRequestOpts,WatchOpts,GitHubMcpServer,UploadBody. knip flags them as unused exports, but they appear in public method signatures. If anything they should be exported from the entry point, not removed, so I left them for a separate decision.Not included, to avoid overlap or non-mechanical changes
languageChoicesare already in open PRs refactor(sdk): remove dead code and de-duplicate SDK/CLI helpers #1766 and chore(sdk): de-duplicate file URL signing and stream start handling, drop unused exports #1873.template deleteandtemplate publish(~18 lines) has different filtering and prompts, so merging it would not be mechanical.Commands.connectandPty.connectshare their request setup but build handles differently. I left them alone.Checks
pnpm run format,pnpm run lintandpnpm run typecheckpass.tests/sandbox/commands/kill.test.ts,tests/sandbox/pty/kill.test.ts,sandboxKilledDuringRun,commandHandleandtests/envdpass (111 tests).test_cmd_kill,test_pty_killandtest_sandbox_killed_during_runpass for both sync and async (10 tests).template/init.test.tsandtemplate/migrate.test.tspass (42 tests), and theparseLanguageaccept/reject paths were spot-checked..changeset/share-process-kill.md).Link to Devin session: https://app.devin.ai/sessions/84e5e0cd7f224b44b138783a32169203
Open in Devin Desktop: https://app.devin.ai/desktop/session/84e5e0cd7f224b44b138783a32169203?variant=devin