Skip to content

Add sb.terminate({ wait: true }) parameter to JS#277

Merged
thomasjpfan merged 1 commit intoehdr/dir-snapshots-non-expfrom
ehdr/terminate-and-wait-js
Feb 19, 2026
Merged

Add sb.terminate({ wait: true }) parameter to JS#277
thomasjpfan merged 1 commit intoehdr/dir-snapshots-non-expfrom
ehdr/terminate-and-wait-js

Conversation

@ehdr
Copy link
Contributor

@ehdr ehdr commented Feb 19, 2026

No description provided.

@cursor
Copy link

cursor bot commented Feb 19, 2026

PR Summary

Low Risk
Small, backwards-compatible API extension in the JS client with test updates; risk is limited to subtle behavioral changes around termination/detach ordering when wait is used.

Overview
Adds SandboxTerminateParams and overloads Sandbox.terminate() to accept terminate({ wait: true }), which waits for completion and returns the sandbox exit code (otherwise preserves the void behavior).

Exports the new type from src/index.ts and updates sandbox/proxy tests to assert terminate({ wait: true }) === 137 instead of terminating and then re-attaching to call wait() separately.

Written by Cursor Bugbot for commit 5ae8aac. This will update automatically on new commits. Configure here.

@ehdr ehdr requested a review from thomasjpfan February 19, 2026 21:54
@thomasjpfan thomasjpfan merged commit 568f6ee into ehdr/dir-snapshots-non-exp Feb 19, 2026
6 checks passed
@thomasjpfan thomasjpfan deleted the ehdr/terminate-and-wait-js branch February 19, 2026 23:56
thomasjpfan added a commit that referenced this pull request Feb 20, 2026
)

* Only image mount

* Less changes

* Introduce detach back

* Make sure terminate actually calls terminate

* Remove the need for ALPN workaround

* Add docs

* Fix lint

* Simplify tls implemetnation

* Give terminate error a higher priority

* Make diff smaller

* Less diff

* Ensure that sandbox is attached before running any operation

* Less diff

* Remove ts detach

* Allow for terminate to happen

* Use two mutexes

* Use atomic bool

* Remove profile.TaskCommandRouterInsecure

* Terminate no longer detaches

* Add detach everywhere

* Update examples

* Add changelog

* Add example to readme

* Add ensureAttached to be extra safe

* Use a better error message

* Add detach and params to Sandbox.Terminate

* Update changelog

* Fix linter

* Do not detach

* Add terminate back in

* Switch order

* Allow for double terminate

* Revert "Allow for double terminate"

This reverts commit 0a12fb8.

* Make more things private

* Add Detach semantics everywhere

* Fix test and go lint

* Revert "Fix test and go lint"

This reverts commit 71d3723.

* Revert "Add Detach semantics everywhere"

This reverts commit c73180a.

* Do simple detach

* Use postiive phrasing

* Fix bug

* Simplify detach

* Fix compareandswap bug

* Use ClientClosedError

* Remove js

* Add unit test

* Fix grammar

* Fix race in task command router init

* Test refreshJwt recovery on error

* Fix refreshJwt retries

* Add Sandbox.detach in JS

* Handle init race

* Mark detached after TCR is closed

* Invert the logic and track attached, not detached

* Prevent race

* Fix elint ignore

* Align ClientClosedError behavior in JS with Go

* Detach when terminating Sandboxes in JS

* JS formatting

* Fix tests

* Graduate mountImage and snapshotDirectory from experimental status

* JS formatting

* Add sb.terminate({ wait: true }) parameter to JS (#277)

* Fix merge issue

* Add more docs

* Remove comment

* Fix lint

---------

Co-authored-by: Thomas J. Fan <thomas@modal.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants