prisma: Fail to build Prisma with nuxt3 for Cloudflare Workers (via Wrangler)

Bug description

process.stderr.fd is not available in cloudflare workers context, which is used in debug-js/debug

Might be related:

How to reproduce

  1. Setup prisma with nuxt3, I used https://sidebase.io/sidebase/welcome/stacks#merino
  2. Run NITRO_PRESET=cloudflare yarn build
  3. Run npx wrangler dev .output/server/index.mjs --site .output/public --local (see https://nitro.unjs.io/deploy/providers/cloudflare)
  4. See error

Starting a local server log:

[mf:err] return "colors" in i.inspectOpts ? Boolean(i.inspectOpts.colors) : l.isatty(process.stderr.fd);

TypeError: Cannot read properties of undefined (reading 'fd')
    at Function.useColors (node_modules/@prisma/client/runtime/index.js:2639:112)
    at default (node_modules/@prisma/client/runtime/index.js:2243:41)
    at src_default (node_modules/@prisma/client/runtime/index.js:19943:43)
    at decompressFromBase64 (node_modules/@prisma/client/runtime/index.js:20021:14)
    at node_modules/@prisma/client/runtime/index.js:33263:38
    at .nuxt/dist/server/_nuxt/error-500.b19bab8c.js:68:72
    ...

Build log on Cloudflare:

Error: Failed to publish your Function. Got error: Uncaught TypeError: Cannot read properties of undefined (reading 'fd')
  at ... in useColors
  at ... in createDebug
  at ... in debugCall

Expected behavior

No response

Prisma information

// unrelevant
export default eventHandler((event) => {
  if (!prisma) {
    prisma = new PrismaClient({ errorFormat: 'minimal' })
  }
  event.context.prisma = prisma
})

Environment & setup

  • Operating System: Darwin, macOS 13.3, Apple M1 Pro
  • Database: PostgreSQL
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0
  • Nitro Version: 1.0.0
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: modules, build, typescript
  • Runtime Modules: @nuxtjs/tailwindcss@6.6.5, @huntersofbook/naive-ui-nuxt@0.5.1
  • Build Modules: -

Prisma Version

4.9.0

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

@janpio what happens if you switch to @prisma/client/edge?