Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: write EPIPE on large files - Next.js + Jest + Supertest #824

Open
3 tasks done
dasveloper opened this issue Jul 25, 2023 · 3 comments
Open
3 tasks done

Error: write EPIPE on large files - Next.js + Jest + Supertest #824

dasveloper opened this issue Jul 25, 2023 · 3 comments
Labels

Comments

@dasveloper
Copy link

Describe the bug

Node.js version: v18.14.2

OS version: macOS 13.4

Description: With Next.js + Jest + Supertest, when attaching a 10mb file to my post request I'm getting the error "write EPIPE"

Actual behavior

Test fails with the error "write EPIPE"

Screenshot 2023-07-24 at 8 42 24 PM

Expected behavior

Test should succeed with no error

Code to reproduce

https://github.com/dasveloper/next-test-supertest

    await testClient(endpointHandler)
      .post("/endpoint")
      .field("name", "John Doe")
      .attach("avatar", Buffer.from("a".repeat(10000000)), "filename")
      .expect({ success: true })
      .expect(200);

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
@dasveloper dasveloper added the bug label Jul 25, 2023
@bploetz
Copy link

bploetz commented Nov 16, 2023

We have a pretty vanilla express.js app (a REST API) that uses supertest with mocha for testing. We recently upgraded it from Node.js 14.15.5 to the latest Node.js 18.x release (18.18.2) and all of a sudden the tests which upload files via the attach function started failing with this error:

Error: write EPIPE
      at afterWriteDispatched (node:internal/stream_base_commons:160:15)
      at writeGeneric (node:internal/stream_base_commons:151:3)
      at Socket._writeGeneric (node:net:962:11)
      at Socket._write (node:net:974:8)
      at doWrite (node:internal/streams/writable:411:12)
      at clearBuffer (node:internal/streams/writable:572:7)
      at Writable.uncork (node:internal/streams/writable:351:7)
      at connectionCorkNT (node:_http_outgoing:951:8)
      at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

After much Googling I stumbled on this issue. The files we're uploading in our tests were images 100K in size, so I tried replacing them with a 1x1 pixel JPEG that is only 3K in size, but the error still occurred, so despite what the OP suggests, I'm not convinced this has anything to do with file size of the attachment.

The only thing that we changed was the Node.js version, and we kept all other dependency versions the same, so clearly something in Node.js was breaking this. Given that, I started downgrading Node.js from 18.18.2 to find where it starts breaking, and it starts breaking in Node.js 18.13.0

Here are the release notes for Node.js 18.13.0:

https://nodejs.org/en/blog/release/v18.13.0

@ajfranzoia
Copy link

@bploetz have you found a solution to this issue?

@bploetz
Copy link

bploetz commented May 27, 2024

@ajfranzoia nope :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants