Skip to content

fix(js-sdk): return from iterateEvents on end instead of break#1157

Open
beran-t wants to merge 1 commit intomainfrom
fix-iterate-events-return
Open

fix(js-sdk): return from iterateEvents on end instead of break#1157
beran-t wants to merge 1 commit intomainfrom
fix-iterate-events-return

Conversation

@beran-t
Copy link
Contributor

@beran-t beran-t commented Feb 25, 2026

Summary

  • Replace break with return in the "end" case of CommandHandle.iterateEvents() so the async generator exits immediately once the command result is captured, instead of continuing to wait for the transport-level gRPC stream to close.

Test plan

  • pnpm run typecheck passes
  • pnpm run lint passes
  • pnpm run format passes (no changes)

@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2026

⚠️ No Changeset found

Latest commit: 6815c8f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

Package Artifacts

Built from 128f096. Download artifacts from this workflow run.

JS SDK (e2b@2.13.1-fix-iterate-events-return.0):

npm install ./e2b-2.13.1-fix-iterate-events-return.0.tgz

CLI (@e2b/cli@2.7.2-fix-iterate-events-return.0):

npm install ./e2b-cli-2.7.2-fix-iterate-events-return.0.tgz

Python SDK (e2b==2.14.0+fix-iterate-events-return):

pip install ./e2b-2.14.0+fix.iterate.events.return-py3-none-any.whl

@beran-t beran-t force-pushed the fix-iterate-events-return branch 3 times, most recently from 63e5ab4 to 0930167 Compare February 25, 2026 15:42
On receiving the "end" event in iterateEvents(), call
handleDisconnect() to abort the transport controller, then return
from the generator to stop blocking on the stream.

In handleEvents(), ignore iteration errors when a result has already
been captured since the error is from the expected abort. After the
generator exits, fire a .next() call on the events stream to trigger
connectrpc's deadline timer cleanup — on platforms where abort
propagates to the body reader (Deno) this clears the timer
immediately; on Node.js (nodejs/undici#1940) it settles when the
server closes the stream.
@beran-t beran-t force-pushed the fix-iterate-events-return branch from 0930167 to 6815c8f Compare February 25, 2026 16:08
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.

1 participant