Repository navigation
Conversation
|
@zsilbi is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds Cloudflare Durable Objects and Workflows support to Nitro through dev-worker composition, Cloudflare runtime binding propagation, documentation, an end-to-end example, and Vite integration tests. ChangesCloudflare Durable Objects Integration
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Title checkExplanation The title follows the Conventional Commits format with the Full details: Description checkExplanation The description is directly related to the changeset. It explains the dev worker composition, static exports, Miniflare integration, HMR behavior, environment forwarding, linked issue, and documentation update. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/cloudflare-durable/routes/counter.ts`:
- Around line 4-8: The code assumes event.req.runtime?.cloudflare?.env exists
and directly casts it, which will throw a TypeError if missing; update the
handler (defineHandler) to validate that event.req.runtime?.cloudflare?.env is
defined and that env.COUNTER exists before calling
env.COUNTER.getByName("global"), and throw a clear, descriptive error (e.g.,
"Missing Cloudflare Durable Object binding: COUNTER") so callers get an
actionable message instead of a runtime TypeError; reference the env variable
and the COUNTER DurableObjectNamespace/CounterDO binding when adding the checks.
In `@src/presets/cloudflare/dev.ts`:
- Around line 149-153: IPC can call loadDevWorker() before
globalThis.__ENV_RUNNER_UNSAFE_EVAL__ is set, so guard and lazily initialize
that binding instead of dereferencing it; create a small helper (e.g.,
ensureUnsafeEval or createUnsafeEvalBinder) that if
globalThis.__ENV_RUNNER_UNSAFE_EVAL__ is undefined will initialize and assign a
safe fallback object exposing newAsyncFunction (built via the Function
constructor to return import(id) so it behaves like the real binder), then use
that helper when computing devWorkerPromise and in the other block (the similar
166-173 code) so loadDevWorker() never calls undefined.newAsyncFunction;
reference globalThis.__ENV_RUNNER_UNSAFE_EVAL__, devWorkerPromise,
loadDevWorker, newAsyncFunction, devWorkerId, and the ipc.onOpen / ipc.onMessage
pre-load paths when locating where to add the helper and replace direct
dereferences.
- Around line 152-154: The memoized devWorkerPromise (devWorkerPromise) is set
with ??= which leaves a permanently rejected promise on transient import
failures; update the promise chain returned by
newAsyncFunction(...)(devWorkerId) to attach a .catch handler that clears
devWorkerPromise (set it to undefined/null) before rethrowing the error so
subsequent attempts will retry, while keeping the successful .then branch that
sets devWorker; reference devWorkerPromise, devWorker, devWorkerId and the
newAsyncFunction(...).then(...) chain when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c8e33f58-1f23-4169-8454-e9ebef5545cd
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (23)
docs/2.deploy/20.providers/cloudflare.mdexamples/cloudflare-durable/README.mdexamples/cloudflare-durable/exports.cloudflare.tsexamples/cloudflare-durable/index.htmlexamples/cloudflare-durable/nitro.config.tsexamples/cloudflare-durable/package.jsonexamples/cloudflare-durable/routes/counter.tsexamples/cloudflare-durable/server/durable/counter.tsexamples/cloudflare-durable/tsconfig.jsonexamples/cloudflare-durable/vite.config.tsexamples/cloudflare-durable/wrangler.jsoncsrc/build/vite/env.tssrc/presets/cloudflare/dev.tssrc/presets/cloudflare/entry-exports.tssrc/presets/cloudflare/utils.tssrc/runtime/internal/vite/dev-worker.mjstest/examples.test.tstest/vite/cloudflare-do-fixture/durable/counter.tstest/vite/cloudflare-do-fixture/durable/entrypoint.tstest/vite/cloudflare-do-fixture/exports.cloudflare.tstest/vite/cloudflare-do-fixture/routes/counter.tstest/vite/cloudflare-do-fixture/vite.config.tstest/vite/cloudflare-do.test.ts
d4b7ccd to
12cf095
Compare
357dd96 to
078fa53
Compare
078fa53 to
918a0b8
Compare
|
Rebased this onto latest One real bug found: the example's Otherwise the dev-worker composition and the DO/workflow tests look good. Note this overlaps with #3875 (durable binding names) and #3238 (wrangler env) — worth landing this one first. This comment was written by an AI assistant on behalf of the Nitro maintainers. Please double-check anything that looks wrong. |
db8a81e to
a546ce5
Compare
|
Hi. Thanks for PR and sorry for late reply. #4677 should already cover objective of this. Lets merge via it. |
Follow-up to #4338 — makes durable object and workflows usable in
dev(miniflare runner).🔗 Linked issue
#4339
❓ Type of change
📚 Description
Compose a dev worker entry that statically re-exports binding-referenced classes from
exports.cloudflare.ts(bundled with rolldown) and pass them to env-runner viaexports— workerd requires them as static exports, while the app keeps loading through the Vite module runner (HMR intact, DO class changes need a restart - documented).Forward
env/ctxto the app in the dev worker, same as the prod module handler (globalThis.__env__+req.runtime.cloudflare).📝 Checklist