This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
HTTP client request.abort() race condition for requests with bodies #1399
Labels
Comments
This patch looks good to me. @Ryah can you take a quick look? |
I think I'm experiencing the same bug. http = require 'http'
http.createServer (req, res) ->
res.writeHead 200, {'Content-Type': 'text/plain'}
# not calling res.end()
.listen 3000, ->
req = http.get {host:'127.0.0.1', path:'/', port:3000}, (res) ->
# This is never called - I wonder if the head is buffered waiting for data?
console.log res.statusCode
setTimeout (-> req.abort()), 1000
# This error handler gets called.
req.on 'error', (e) -> console.warn e.stack
|
I think this bug has been fixed in the new http library but @SaltwaterC's test demonstrates another issue. His test case, modified to listen for errors: var common = require('../test/common');
var assert = require('assert');
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end();
});
server.listen(common.PORT, function() {
var cont = 'foo=bar';
var opt = {
port: common.PORT,
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
'content-length': cont.length
}
};
var req = http.request(opt);
req.on('error', function(e) {
console.error(e);
console.trace();
});
req.write(cont);
req.abort();
req.end(); // the race condition happens here as the connection is destroyed by req.abort()
server.close();
}); Produces this:
Looks like the |
bnoordhuis
added a commit
to bnoordhuis/node
that referenced
this issue
Nov 3, 2011
It was emitting the net.Socket object due to misuse of the arguments object. Fixes nodejs#1399.
Closed
just saw this fix, thanks! looks great! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Here's a test that proves it:
Still trying to figure out if this is related to #796. Couldn't write a server that reproduces the "TypeError: Cannot read property '_httpMessage' of null" exception. This client does it every time.
The text was updated successfully, but these errors were encountered: