Skip to content

fix(js-sdk): snapshot queued Buffer input bytes - #2152

Open
Elon-Jiang wants to merge 1 commit into
e2b-dev:mainfrom
Elon-Jiang:fix/stream-input-buffer-snapshot
Open

Elon-Jiang wants to merge 1 commit into
e2b-dev:mainfrom
Elon-Jiang:fix/stream-input-buffer-snapshot

Conversation

@Elon-Jiang

@Elon-Jiang Elon-Jiang commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

Queued command/PTY input already snapshots Uint8Array data, but Node.js Buffer.slice() returns a view. Reusing a Buffer after send() therefore changes bytes that have not yet been transmitted.

Copy with new Uint8Array(data) instead of calling the input's slice() method. Keep ordering, strings, keepalives and close/error handling unchanged. Add a patch changeset.

const input = sandbox.commands.streamInput(pid) // also sandbox.pty.streamInput(pid)
const bytes = Buffer.from('original')
await input.send(bytes)
bytes.fill(120)
await input.close()
// The queued payload stays "original", rather than becoming "xxxxxxxx".

Validation

  • Test-first public-interface tracer fails on unchanged main c4bab34 and passes with the one-line fix.
  • Expanded unchanged-source matrix: 6 failed, 6 passed. After fix: 12 passed.
  • Related input/command/transport selection: 135 passed.
  • Required repository pnpm run format, pnpm run lint, pnpm run typecheck (including SDK builds), and git diff --check: passed. Four lint warnings are in untouched files.

The regressions use public Sandbox.connect('offline-sandbox', {debug:true}), command/PTY streamInput, send and close, with the actual SDK and Connect JSON request encoding. A gated fetch-boundary fixture consumes encoded request bytes and supplies the envd acknowledgement. No live cloud sandbox or guest process was used. Coverage includes ordinary/sliced/binary Buffers, plain Uint8Array and string controls for both input kinds.

Python sync/async APIs accept immutable str/bytes; they have no Node Buffer slice counterpart. No Python change or new guide/API workflow is needed to restore this existing snapshot behavior.

Related: streamInput was introduced in #1997 for SDK-393. Current open PR files, behavioral/symbol searches and complete path history were checked for overlap.

AI assistance: OpenAI Codex prepared the patch and ran validation.


Devin Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T03:16:26.369447Z e5fc29b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@changeset-bot

changeset-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e5fc29b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
e2b Patch

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TASTE.md review (checked T-1/T-2 parity, T-17 input types, T-19 data typing, T-26 handles, T-59/T-62 errors): 0 violations. The internal new Uint8Array(data) copy leaves the public surface unchanged, and Python's send is typed Union[str, bytes] (immutable), so no sync/async mirror is needed.

Written by Devin

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant