Skip to content

D1 bindings not accessible in dev with nitro-cloudflare-dev #741

@onmax

Description

@onmax

Problem

When using nitro-cloudflare-dev for local D1 emulation, NuxtHub cannot find bindings during startup.

nitro-cloudflare-dev sets globalThis.__env__ as a Promise initially. NuxtHub accesses globalThis.__env__?.DB synchronously, which returns undefined because the Promise object doesn't have a DB property.

Reproduction

git clone --depth 1 --filter=blob:none --sparse https://github.com/onmax/repros.git
cd repros && git sparse-checkout set nuxthub-741
cd nuxthub-741 && pnpm i && pnpm dev

Console shows:

🔥 Cloudflare context bindings enabled for dev server
[nuxt:hub] ERROR Failed to create migrations table
DB binding not found

Expected

Migrations run successfully with local D1 emulation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions