Repository navigation
Add Sandbox.execStream() and abort signals; prepare 2.2.0 for npm - #70
Merged
Merged
Conversation
After yielding the exit event, the exec generator keeps reading until the response ends. An abort in that window made the loop, or exec(), throw the signal's reason for a command that had already finished. Once the exit event has been delivered, an abort now ends the stream normally.
…he command Like aborting, leaving the loop early (break, return or an exception) only closes the connection: the command keeps running until it exits or reaches its timeout, 60 seconds by default.
bo-deepinfra
approved these changes
Nov 12, 2026
bo-deepinfra
left a comment
There was a problem hiding this comment.
LGTM. exec() folding execStream()'s events keeps its old behaviour, including the missing-return-code error. The abort handling is right: the caller's reason wins over the transport error, and an abort after the exit event ends the stream cleanly. Breaking out of the loop destroys the response body, and the tests cover all three cases. On the workflow: checkout@v7 and setup-node@v7 exist, id-token: write is set, and repository.url matches this repo, which trusted publishing needs. NPM_TOKEN stays as the fallback.
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.
Adds streaming to sandbox
execand gets the package ready for npm. npm still has only 2.0.2: the 2.1.0 publish job failed, so the Sandbox API has not shipped there yet.sb.execStream(cmd, ...args, options?)yields{ type: "stdout" | "stderr", data }while the command runs, then one{ type: "exit", returncode }.exec()folds the same stream and behaves as before.{ signal }onexec()andexecStream(): aborting throws the signal's reason. The command keeps running in the sandbox until it exits or reaches itstimeout.dist/, thetypesriptkeyword is fixed, and the version is 2.2.0.deploy.ymlmoves to npm trusted publishing (needs npm 11.5.1+, hence Node 24) and keepsNPM_TOKENas the fallback. The logs of the failed 2.1.0 job have expired, so it is unknown whether the current token still works; adding the trusted publisher on npmjs.com before the release (steps inRELEASE.MD) avoids depending on it.Test results
The packed tarball, installed in a fresh project and run against the live API:
exitwith the script's codeAbortErrorat onceAbortSignal.timeout(1500)onexec()TimeoutErrorafter 1.50 sbreakout of the loop of a 20 s commandexec()workstimeoutSandboxExecErrorrequire,import, andtsc --strictundernodenext/bundler/node10examples/sandbox-quickstart.tsNot covered: the publish job itself, which runs only on a release.
npm publish --dry-runpasses.