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.

Write after end when piping

See original GitHub issue

I have a fairly simple case where I’m building a tarball-stream on the fly and piping it to a request that’s going through follow-redirects.

It almost immediately crashes with this error:

Error: write after end
    at ClientRequest.OutgoingMessage.write (_http_outgoing.js:439:15)
    at Writable.RedirectableRequest._write (/home/espenh/webdev/sanity/cli/node_modules/follow-redirects/index.js:170:23)
    at doWrite (_stream_writable.js:333:12)
    at clearBuffer (_stream_writable.js:440:7)
    at onwrite (_stream_writable.js:372:7)
    at WritableState.onwrite (_stream_writable.js:89:5)
    at CorkedRequest.finish (_stream_writable.js:547:7)
    at afterWrite (_stream_writable.js:387:3)
    at onwrite (_stream_writable.js:378:7)
    at TLSSocket.WritableState.onwrite (_stream_writable.js:89:5)

I’ll see if I can find time to write a reduced test case at some point, but don’t have time right at this moment. Switching to regular HTTP/HTTPS for this request fixes the problem.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RubenVerborghcommented, Jun 21, 2017

This fixes @olalonde’s test case. Please verify.

0reactions
RubenVerborghcommented, Jan 9, 2019

@rwpino Thanks, replied there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Write after end when piping a ClientRequest to ServerResponse
I believe that finished and writable should have opposite values, since when a OutgoingMessage is closed - it is not writable anymore and...
Read more >
NodeError: write after end in NodeJS - Stack Overflow
Your problem is that you're reusing the same cipher multiple times. After it's used in a stream once, it cannot be reused; a...
Read more >
Stream | Node.js v19.3.0 Documentation
A key goal of the stream API, particularly the stream.pipe() method, ... Calling the stream.write() method after calling stream.end() will raise an error....
Read more >
minipass - npm
Since data written to a Minipass stream is immediately written all the way through the pipeline, and write() always returns true/false based ...
Read more >
Streams, Piping, and Their Error Handling in Node.js - Medium
Streams, Piping, and Their Error Handling in Node.js, explained with examples. ... Error [ERR_STREAM_WRITE_AFTER_END]: write after end
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