Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Calling write() after calling end() not raising an error #7477

Closed
luiscvega opened this issue Apr 17, 2014 · 7 comments
Closed

Calling write() after calling end() not raising an error #7477

luiscvega opened this issue Apr 17, 2014 · 7 comments
Milestone

Comments

@luiscvega
Copy link

According to docs, the code below should raise an error.

"Calling write() after calling end() will raise an error." (http://nodejs.org/api/stream.html#stream_writable_end_chunk_encoding_callback)

var http = require("http");

http.createServer(function (req, res) {
  res.write("This should write.");
  res.end();
  res.write("This should raise an error but it does not.");
}).listen(3000);
@indutny indutny added this to the v0.12 milestone Apr 17, 2014
@indutny
Copy link
Member

indutny commented Apr 17, 2014

Heh, thanks for catching this. It is actually a http module weirdness. I wish we would fix it after initial v0.12 release.

@luiscvega
Copy link
Author

Cool. I think ending an already ended response should also error, but doesn't right now. And I think all this is the same for the request.

Glad to be of help. :)

misterdjules pushed a commit to misterdjules/node that referenced this issue Sep 23, 2014
When calling write() after end() has been called on an OutgoingMessage,
an error is emitted and the write's callback is called with an instance
of Error.

Fix nodejs#7477.
@misterdjules
Copy link

@luiscvega @indutny I just created a PR that fixes this issue.

misterdjules pushed a commit to misterdjules/node that referenced this issue Sep 23, 2014
When calling write() after end() has been called on an OutgoingMessage,
an error is emitted and the write's callback is called with an instance
of Error.

Fix nodejs#7477.
indutny pushed a commit that referenced this issue Sep 23, 2014
When calling write() after end() has been called on an OutgoingMessage,
an error is emitted and the write's callback is called with an instance
of Error.

Fix #7477.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
@mscdex
Copy link

mscdex commented Sep 23, 2014

Should we really emit 'error' if they've already supplied a callback and we're passing the error to that callback?

@misterdjules
Copy link

@mscdex My implementation was modeled after _stream_writable.js' writeAfterEnd, but now that you ask the question it also feels like it's a bit too much to ask for. @indutny @tjfontaine What do you think?

@indutny
Copy link
Member

indutny commented Sep 23, 2014

@mscdex I think they follow streams2 approach, whatever it is right now.

@trevnorris
Copy link

Fixed by 64d6de9.

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

No branches or pull requests

5 participants