core icon indicating copy to clipboard operation
core copied to clipboard

Wrangler compatibility issues

Open hcmlopes opened this issue 6 months ago • 4 comments

Cannot use nuxtHub database when initializing a new project with the hello-edge template or by following the Add to Nuxt project instruction.

Steps to reproduce the behavior:

  1. Initialize new project by running npx nuxthub init my-app
  2. run cd my-app
  3. run pnpm dev
  4. errors
    • Failed to initialize wrangler bindings proxy write EPIPE
    • [unhandledRejection] Missing Cloudflare DB binding (D1)

Expected behavior No errors

Steps taken to remove error Downgrade wrangler devDependency to 3.104. Any version past this will result in the previously mentioned error

  1. run pnpm add [email protected]
  2. run pnpm dev
  3. no error

hcmlopes avatar Jul 01 '25 19:07 hcmlopes

Getting the same Missing Cloudflare DB binding (D1) issue here with a brand new install, although it only happens when doing npx nuxt build && npx nuxthub preview – running in the usual dev works fine.

Downgrading my wrangler version to 3.104 doesn't fix it either

zacwebb avatar Jul 06 '25 05:07 zacwebb

Do you use linux? Can you provide the output of npx nuxi info?

Missing Cloudflare bindings in local machine, means that worked couldn't simulate worker environment in your machine.

@zacwebb Do you have same issue with NuxtHub starter? npx nuxthub init my-app

farnabaz avatar Jul 18 '25 08:07 farnabaz

Do you use linux? Can you provide the output of npx nuxi info?

Nah MacOS Sequoia. Here's my nuxi info ouptut @farnabaz:

------------------------------
- Operating System: Darwin
- Node Version:     v24.0.2
- Nuxt Version:     3.17.5
- CLI Version:      3.25.1
- Nitro Version:    2.11.12
- Package Manager:  [email protected]
- Builder:          -
- User Config:      modules, devtools, runtimeConfig, future, compatibilityDate, hub, eslint
- Runtime Modules:  @nuxthub/[email protected], @nuxt/[email protected]
- Build Modules:    -
------------------------------

@zacwebb Do you have same issue with NuxtHub starter? npx nuxthub init my-app

Yep same issue, I tried:

  1. Fresh install with npx nuxthub init my-app
  2. Update nuxt.config.js to have hub.database = true
  3. Add a D1 call in the server, e.g. in server/api/ping.ts add:
export default eventHandler(async () => {
  // Example query from https://hub.nuxt.com/docs/features/database#prepare
  const result = await hubDatabase().exec(`CREATE TABLE IF NOT EXISTS frameworks (id INTEGER PRIMARY KEY, name TEXT NOT NULL, year INTEGER NOT NULL DEFAULT 0)`)
  console.log(result)

  return 'pong'
})
  1. Run npx nuxt build && npx nuxthub preview
  2. Navigate to http://localhost:[port]/api/ping and see Missing Cloudflare DB binding (D1)

zacwebb avatar Jul 18 '25 23:07 zacwebb

@zacwebb This is expected behavior in built version. When you build the project, module does not provide local fallback for bindings (including database) and therefore you can't run built version in your local machine.

Try publishing the build to Cloudflare and it will work as expected.

farnabaz avatar Jul 22 '25 08:07 farnabaz