Skip to content

[BUG] worker binding cannot be exposed #1264

Description

@AugustinMauroy

Describe the bug

context

If you want to e2e test you authed next app that use better auth you may use https://better-auth.com/docs/plugins/test-utils with you prisma that use CF binding https://opennext.js.org/cloudflare/howtos/db#prisma-orm

Issue

when calling auth utilizes it's throw ERROR: getCloudflareContexthas been called without having calledinitOpenNextCloudflareForDev from the Next.js config file.

Why ?

Because test with playwright are ruined in node.js context and not in next/open-next/wrangler context. which create an issue because auth utility cannot use prisma client because he didn't have D1

Solution

Having api that feed playwright env. I'm pretty sure that it's already exist but that's a lack of docs.

Steps to reproduce

  1. run test
  2. see the error

Expected behavior

test utile work correctly with prisma client that use d1 binding to interact with same d1 than dev server

@opennextjs/cloudflare version

1.19.9"

Wrangler version

4.90.0

next info output

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:31 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 25.7.0
  npm: 11.10.1
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.2.6 // Latest available version is detected (16.2.6).
  eslint-config-next: N/A
  react: 19.2.6
  react-dom: 19.2.6
  typescript: 6.0.3
Next.js Config:
  output: N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions