Skip to content

Fix race condition in sandbox multi-file writes - #233

Open
ayushnandi718-dev wants to merge 1 commit into
e2b-dev:mainfrom
ayushnandi718-dev:main
Open

Fix race condition in sandbox multi-file writes#233
ayushnandi718-dev wants to merge 1 commit into
e2b-dev:mainfrom
ayushnandi718-dev:main

Conversation

@ayushnandi718-dev

Copy link
Copy Markdown

Problem

Multi-file fragments can execute before all files are written to the sandbox — a race condition in app/api/sandbox/route.ts.

Array.prototype.forEach ignores the promises returned by the async callback. The outer POST handler continues to sbx.runCode(...) / URL return without awaiting the writes.

Fix

Replaced orEach(async) with �wait Promise.all(fragment.code.map(...)) so all files are persisted before execution or URL return.

Closes #229

Replace forEach(async) fire-and-forget with await Promise.all() so
all files are written to the sandbox before code execution starts.

Fixes e2b-dev#229
@cla-bot

cla-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @ayushnandi718-dev on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

@ayushnandi718-dev is attempting to deploy a commit to the E2B Team on Vercel.

A member of the Team first needs to authorize it.

@ayushnandi718-dev

Copy link
Copy Markdown
Author

@cla-bot check i did it

@cla-bot cla-bot Bot added the cla-signed label Jul 14, 2026
@cla-bot

cla-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@ayushnandi718-dev ayushnandi718-dev left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@cla-bot check

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.

Sandbox route: forEach(async) fire-and-forget can run code before multi-file writes finish

1 participant