fix(create-cloudflare): pin h3 to ^1 in the Nuxt template so Cloudflare bindings work in dev with pnpm#14613
Open
lucasmzz wants to merge 2 commits into
Open
fix(create-cloudflare): pin h3 to ^1 in the Nuxt template so Cloudflare bindings work in dev with pnpm#14613lucasmzz wants to merge 2 commits into
lucasmzz wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 92cf49f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers |
workers-devprod
approved these changes
Jul 9, 2026
workers-devprod
left a comment
Contributor
There was a problem hiding this comment.
Codeowners reviews satisfied
@cloudflare/autoconfig
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
Contributor
|
I just tried out the prerelease and I see v2.0.1-rc.23 of |
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.
Hotfix for fixing a regression in the Nuxt (Workers) template for pnpm users — no existing issue filed. Upstream PR to be opened to
nitro-cloudflare-devfor fixing the root cause.Problem
Scaffolding a project with
pnpm create cloudflare@latest→ Nuxt currently produces an app whereevent.context.cloudflareisundefinedin every server route duringnuxt dev, so D1/KV/R2 bindings are unreachable in local development:Root cause
The template's
configurestep installs a bareh3for pnpm users (so theH3EventContextaugmentation in the shippedenv.d.tscan resolve
h3under pnpm's isolated, non-hoistingnode_moduleslayout). h3'slatestnpm dist-tag now points at the 2.x releasecandidates (
2.0.1-rc.23at the time of writing; the v1 line lives under the1xtag), so this installsh3@2.0.1-rc.xas a directdevDependency while Nuxt 4 / nitropack 2.x run on
h3@^1.15.11.With two h3 majors installed, Nitro's auto-import layer resolves the bare
h3specifier from the project root (v2), while the serverapp itself runs on nitropack's nested v1. The generated dev bundle (
.nuxt/dev/index.mjs) imports from both copies. Thenitro-cloudflare-devrequest hook then calls h3 v2'sgetRequestURL(event)on an h3 v1 event, which throwsTypeError: Cannot read properties of undefined (reading 'url')before it assignsevent.context.cloudflare. Nitro swallows request-hook errors(
callHook("request", event).catch(captureError)), so the request proceeds without bindings and the user's route crashes instead.Fix
Install
h3@^1, matching the h3 major that nitropack depends on. Pinning (rather than dropping the pnpm-only install) is deliberate:without a root-level
h3, thedeclare module "h3"augmentation inenv.d.tsno longer resolves under pnpm, andevent.context.cloudflareloses its types — which is why the template installs h3 in the first place.the generated
package.jsongets"h3": "^1.15.11", the dev bundle references onlyh3@1.15.11, and a server route readingevent.context.cloudflare.env(D1 query) returns results innuxt dev. Also confirmedevent.context.cloudflaretyping stillresolves.
Two small notes:
either way, the "Create pull request" button from the link in your push output
(https://github.com/lucasmzz/workers-sdk/pull/new/c3-nuxt-pin-h3-v1) targets cloudflare/workers-sdk main by default.
so the PR itself serving as the discussion is reasonable — but if you'd rather be safe, you can file a short bug issue first and swap
its number into the "Fixes #" line.