Skip to content

[BUG] Prisma throws Error: [unenv] fs.readdir is not implemented yet! when querying #623

@schweetheart

Description

@schweetheart

Describe the bug

After following the Cloudflare workers with PostgreSQL tutorial.

When making a query via prisma client Error: [unenv] fs.readdir is not implemented yet! is thrown when running via the workers runtime pnpm preview.

When using a worker directly, Prisma works correctly.

// schema.prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Post {
  id        Int      @id @default(autoincrement())
  title     String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}
// page.tsx
export default async function Home() {
  
// Force SSR
  connection();

  const connectionString = "example"

  const adapter = new PrismaPg({ connectionString });
  const prisma = new PrismaClient({ adapter });

  const posts = await prisma.post.findMany();
  return (
    <div>
      <div>{Date()}</div>
      <div>{JSON.stringify(posts)}</div>
    </div>
  );
} 
Image

Steps to reproduce

  1. Clone the minimal reproduction
  2. Set DATABASE_URL in .env and .dev.vars with a postgres compatible database. (I used Neon)
  3. Preview the app locally via pnpm preview
  4. Visit http://localhost:3000/
  5. You should see the error in the dialog.

Expected behavior

When running prisma directly in a worker without OpenNext, with the same code the result is working. When running the same code with OpenNext, the error is thrown.
Am I missing some configuration, or is there some unexpected behavior when the OpenNext build process interacts with Prisma.

@opennextjs/cloudflare version

1.0.0-beta.4

Wrangler version

4.14.0

next info output

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.11.1
  npm: 10.8.1
  Yarn: 1.22.19
  pnpm: 9.15.0
Relevant Packages:
  next: 15.3.1 // Latest available version is detected (15.3.1).
  eslint-config-next: 15.3.1
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

Additional context

Setting PRISMA_CLIENT_FORCE_WASM=1 has had no effect. I also tested via the @prisma/adapter-neon adapter with the same error.

It looks like others have encountered the same error recently with different adapters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions