RedwoodJS 22.1 and Prisma 12.1 Workaround for Intermittent: write EPIPE error

I encountered several errors after upgrading to 22.1 with Prisma 12.1especially when using findFirst and findUnique but the issue is not limited to that.

If you happen to see some graphql errors – or even an error and then a retry success – look in your logs (ie Netlify function logs for graphql) and if you see:

ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"write EPIPE","code":"EPIPE","clientVersion":"2.12.1","stack":["Error: write EPIPE","    at PrismaClientFetcher.request (/var/task/dist/webpack:/mnt/ramdisk/project/node_modules/@prisma/client/runtime/index.js:79355:15)","    at processTicksAndRejections (internal/process/task_queues.js:97:5)"]}

and then

ERROR	Uncaught Exception 	{"errorType":"TypeError","errorMessage":"Cannot read property 'onError' of undefined","stack":["TypeError: Cannot read property 'onError' of undefined","    at Socket.ce (/var/task/dist/webpack:/mnt/ramdisk/project/node_modules/@prisma/client/runtime/index.js:25673:45)","    at Socket.emit (events.js:314:20)","    at Socket.EventEmitter.emit (domain.js:483:12)","    at Pipe.<anonymous> (net.js:676:12)"]}

it is likely due to this issue:

What they suspect happened is:

that lambda is cleaning up the /tmp directory and cleaning up our unix domain socket which we use now in the latest version(we were using a TCP port before for Rust <-> communication).

The workaround is to configure your Prisma client as:

export const db = new PrismaClient({
  __internal: {
    useUds: false,
  }
})

If you are getting this behavior, I recommend setting this workaround as – so far – my app is behaving much much better at the moment.

I will update here if I see the issue return.

1 Like

BTW - This issue may not be resolved in Prisma 14 or 15

So, perhaps this workaround may need to get into crwa?

1 Like

Oh my. Huge thanks for recording this and providing all the workaround help @dthyresson :rocket: