feat(batch,snapshot): add --runtime workerd - #134
Merged
Merged
Conversation
yusukebe
force-pushed
the
feat/batch-snapshot-runtime
branch
from
September 18, 2026 01:45
463e71e to
aa0e430
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
`batch` and `snapshot` take `--runtime workerd`, like `request`. One workerd starts from the wrangler config and every step runs in it, so a flow over the real bindings (put to KV, then get; D1; an AI binding) runs in one call with `save` and `expect`. Until now the only way was `request --runtime workerd` per step, which starts workerd each time and cannot carry values between steps. Asked by a user trying an AI-binding middleware.
The workerd code moves to `src/utils/workerd.ts` and splits into a target that can be started once, asked many times, and disposed; `request` keeps using the one-shot form. `runBatch` and `snapshotLines` send to any target with a `request()` method, so a Hono app and a running workerd look the same to them. `snapshot` reads the routes from `main` in-process and sends the requests to workerd. Only `node` and `workerd` are accepted here; `bun`/`deno` point at `request`.
Checked on a real wrangler project: `snapshot --runtime workerd` reports `Cloudflare-Workers` as the user agent, and a KV put-then-get batch passes on one workerd. Known limit, not new: an app that imports `cloudflare:*` modules cannot be imported in-process, so `snapshot` (any runtime) and `routes` fail on it with a build error.
The author should do the following, if applicable
pnpm run format:fix && pnpm run lint:fixto format the code