You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
Calling req.abort() on a very active HTTP request causes Error: stream.push() after EOF in versions 0.10.5+
In this case, a HTTP client that wants to forcefully limit the size of the content it will pull:
client.js
varhttp=require("http")varMAX_SIZE=1024varreq=http.get("http://localhost:1338",function(res){varsize=0res.on("data",function(chunk){size+=chunk.lengthif(size>MAX_SIZE){console.log("Stop the madness! (aborting)")res.removeAllListeners("data")// not required, but prevents a second run of this "data" listenerreq.abort()}})})console.log("Sending request")req.end()
server.js
varhttp=require("http")vars=http.createServer(function(req,res){console.log("incoming")res.writeHead(200,{"Content-Type": "text/plain"})varcount=0for(vari=0;i<1000000;i++){count++res.write("packet "+i+"\n")}console.log("ending, wrote %s",count)res.end()})s.listen(1338)
With 0.10.4 (and below) this works:
bryce@x220:~/flood$ node client.js
Sending request
Stop the madness! (aborting)
bryce@x220:~/flood$
With 0.10.5 (and above) it throws an Error:
bryce@x220:~/flood$ node client.js
Sending request
Stop the madness! (aborting)
events.js:72
throw er; // Unhandled 'error' event
^
Error: stream.push() after EOF
at readableAddChunk (_stream_readable.js:146:15)
at IncomingMessage.Readable.push (_stream_readable.js:127:10)
at HTTPParser.parserOnBody [as onBody] (http.js:140:22)
at Socket.socketOnData [as ondata] (http.js:1553:20)
at TCP.onread (net.js:524:27)
bryce@x220:~/flood$
However, if the server is slowed down (setTimeout with 1ms works, setImmediate causes the same error), it works fine; whether this is a real-world issue is unclear.
The text was updated successfully, but these errors were encountered:
Calling req.abort() on a very active HTTP request causes
Error: stream.push() after EOF
in versions 0.10.5+In this case, a HTTP client that wants to forcefully limit the size of the content it will pull:
client.js
server.js
With 0.10.4 (and below) this works:
With 0.10.5 (and above) it throws an Error:
However, if the server is slowed down (setTimeout with 1ms works, setImmediate causes the same error), it works fine; whether this is a real-world issue is unclear.
The text was updated successfully, but these errors were encountered: