Skip to content

fix: harden pull batch downloads and CLI argument parsing against read errors - #36

Open
adi-IL wants to merge 1 commit into
e2b-dev:mainfrom
adi-IL:fix/download-batch-resilience
Open

fix: harden pull batch downloads and CLI argument parsing against read errors#36
adi-IL wants to merge 1 commit into
e2b-dev:mainfrom
adi-IL:fix/download-batch-resilience

Conversation

@adi-IL

@adi-IL adi-IL commented Aug 31, 2026

Copy link
Copy Markdown

During project download batches, sandbox.files.read is executed across files inside Promise.all. If any file in the batch fails to read (for example, due to broken symlinks, locked files, FIFO pipes, or files deleted in the sandbox between status inspection and download), the unhandled rejection rejects the entire batch Promise.all, aborts all subsequent batches, and crashes the pull command.

Similarly, CLI invocation of download.js passed unvalidated JSON into JSON.parse, dumping an unhandled SyntaxError stack trace instead of exiting cleanly with code 2.

This change:

  • Wraps remote reads in main() and check mode in try/catch blocks, safely recording unreadable or unwriteable files into skipped so the remainder of the batch and subsequent batches complete.
  • Adds try/catch validation around CLI JSON parsing in src/download.js to exit with code 2 and a clean error message.
  • Adds unit tests in test/download.test.js for invalid CLI JSON arguments and missing parameters.

Tests

node --test test/*.test.js
# 286 tests, 0 failures

bash test/cli.test.sh
# 299 tests, 0 failures

@cla-bot cla-bot Bot added the cla-signed label Aug 31, 2026
@adi-IL

adi-IL commented Sep 2, 2026

Copy link
Copy Markdown
Author

Hi @OndrejDrapalik, when you get a chance, could you take a look at this one? It prevents a single unreadable or removed file from aborting the whole Promise.all download batch during pull, and hardens CLI argument parsing in download.js. All 286 unit and 299 CLI tests pass.

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