Skip to content

Add support for batch sync to workerd - #116

Open
aron-cf wants to merge 13 commits into
mainfrom
deferred-sync
Open

Add support for batch sync to workerd#116
aron-cf wants to merge 13 commits into
mainfrom
deferred-sync

Conversation

@aron-cf

@aron-cf aron-cf commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Commands currently wait for the full post-command pull before returning. That works for small changes, but an npm install can create thousands of files and run over a request budget. The default sync filter recently dropped node_modules, so installed packages now survive a replacement workspace runtime.

Sync can now move a fixed number of entries or bytes at a time and resume from a path within one revision. Workspace.push() and Workspace.pull() keep their existing behavior unless the caller selects batch mode. Commands also accept sync: "deferred".

Deferred mode is intended to batch work across several messages/cycles to avoid CPU saturation. The host can call retryPendingSync() from its durable object alarm until the captured target is complete. Though for now the default remains inline sync.

Deferred targets are captured after pending filesystem writes settle. Later commands extend an existing target, successful batches do not consume the failure retry limit, and cancellation waits for the command to finish before recording its target. Runtime replacement and stale cursor handling keep retries from reporting success against the wrong container.

An example of a container-backed workspace that has a SyncRetryScheduler configured:

const handle = await workspace.runtime.exec("npm install", {
  sync: "deferred",
});

const result = await handle.result();
console.log(result.sync.status); // "pending"

let retry = await workspace.retryPendingSync();
while (retry.status === "pending") {
  retry = await workspace.retryPendingSync();
}

After the retry reports "complete", replacing the runtime and running a command that reads node_modules should use the installed files from the workspace store.

@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bc54994

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

@aron-cf
aron-cf marked this pull request as ready for review August 21, 2026 16:50
@pkg-pr-new

pkg-pr-new Bot commented Aug 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/computer@116

commit: bc54994

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

Copy link
Copy Markdown

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 potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

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