Skip to content

Support AbortSignal in JS SDK methods for request cancellation #1312

@abhijit-hota

Description

@abhijit-hota

Is your feature request related to a problem? Please describe.

The SDK's REST-backed methods (Sandbox.create, Sandbox.connect, sandbox.commands.run, sandbox.files.write, etc.) don't accept an AbortSignal. We use signals to cancel in-flight requests, etc. but pending E2B calls can't be cancelled and run to completion regardless.

Describe the solution you'd like

An optional signal: AbortSignal on the request options that aborts the underlying fetch and rejects with an AbortError:

const signal = /* An AbortSignal instance from anywhere */;
await Sandbox.create(template, { apiKey, signal });
await sandbox.commands.run(script, { signal });

Describe alternatives you've considered

Racing each call against the signal with Promise.race. The caller returns early, but the request still runs in the background.

Additional context N/A


Is this something that's possible to add? Any existing solution that I'm missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions