question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

intermittent: write EPIPE + Cannot read property 'onError' of undefined

See original GitHub issue

Bug description

These two exceptions happen in the same flow:

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)"]}

2 milliseconds later:

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)"]}

This was previously masked by #4117, which was fixed by this commit; now the real error is visible.

Possibly related to #4400

How to reproduce

This is an intermittent error on AWS Lambda, could not reproduce it on a dev machine.

Expected behavior

  • No exception (duh)
  • It would be nice to have source mapping to link the stack trace into a specific spot in the code (instead of @prisma/client/runtime/index.js:25673:45).
  • It would be nice to have more logs from the Rust process; IIUC there’s no way to set RUST_LOG to something other than info

Environment & setup

  • OS: AWS Lambda (linux-musl), node 12.x
  • Database: PostgreSQL 12 on RDS
  • Node.js version: 12.18
  • Prisma version: 2.12.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
pantharshit00commented, Dec 21, 2020

I have a theory 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).

Can you all try installing the dev channel and turning off UDS and see if this shows up again:

const prisma = new PrismaClient({
  __internal:{
    useUds: false
  }
} as any) // remove as any if you using js

Similar bug report about uds: https://github.com/prisma/prisma/issues/4744

7reactions
royracommented, Dec 23, 2020

I have a theory 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).

Looks like prisma itself is deleting its socket file on the beforeExit event of the node process. According to this blog post:

The Lambda runtime uses the beforeExit event to complete the last request and start processing the next request.

If this is true, it explains the intermittent error:

  1. The event loop for the lambda container is emptied and beforeHook is called
  2. Prisma deletes its own socket file
  3. More requests are queued to the event loop, causing the same prisma instance to attempt more work
  4. EPIPE

Reverting to tcp socket is a workaround, but the real fix could be unhooking from the beforeExit event.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RedwoodJS 22.1 and Prisma 12.1 Workaround for Intermittent
intermittent : write EPIPE + Cannot read property 'onError' of undefined ... What they suspect happened is: that lambda is cleaning up the...
Read more >
events.js:288 Error: write EPIPE when executing tests with Jest
For me it was a matter of installing the correct version. I know it doesn't sound very logical, but keep trying until you...
Read more >
Changelog - Cypress Documentation
Added the mimeType property so you can explicitly set the mime type on ... the error "cannot read property split of undefined" in...
Read more >
what is a "write EPIPE" error? - Google Groups
resProx.on 'error', (err) ->. log 'dba: uploadAttachment res err event ' + compDoc._id + ' ' + resProx.statusCode, {err}. cb false.
Read more >
Parse Server Error: Uncaught Internal Server Error. {Stack: - ADocLib
... throw errors in situations where Apollo Server doesn't do so automatically. ... intermittent: write EPIPE + Cannot read property 'onError' of undefined....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found