Comparing version 3.4.3 to 3.4.4
@@ -54,7 +54,27 @@ 'use strict'; | ||
var state = this._spdyState; | ||
var stream = state.stream; | ||
if (state.ending) | ||
state.stream.end(callback); | ||
else | ||
state.stream.abort(callback); | ||
if (state.ending) { | ||
// The .end() method of the stream may be called by us or by the | ||
// .shutdown() method in our super-class. If the latter has already been | ||
// called, then calling the .end() method below will have no effect, with | ||
// the result that the callback will never get executed, leading to an ever | ||
// so subtle memory leak. | ||
if (stream._writableState.finished) { | ||
// NOTE: it is important to call `setImmediate` instead of `nextTick`, | ||
// since this is how regular `handle.close()` works in node.js core. | ||
// | ||
// Using `nextTick` will lead to `net.Socket` emitting `close` before | ||
// `end` on UV_EOF. This results in aborted request without `end` event. | ||
setImmediate(callback); | ||
} else if (stream._writableState.ending) { | ||
stream.once('finish', function() { | ||
callback(null); | ||
}); | ||
} else { | ||
stream.end(callback); | ||
} | ||
} else { | ||
stream.abort(callback); | ||
} | ||
@@ -61,0 +81,0 @@ // Only a single end is allowed |
{ | ||
"name": "spdy", | ||
"version": "3.4.3", | ||
"version": "3.4.4", | ||
"description": "Implementation of the SPDY protocol on node.js.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -391,2 +391,22 @@ var assert = require('assert'); | ||
}); | ||
it('should destroy request after end', function(done) { | ||
var stream = client.request({ | ||
method: 'POST', | ||
path: '/post' | ||
}, function(err) { | ||
assert(!err); | ||
}); | ||
stream.end(); | ||
stream.on('error', function() {}); | ||
server.on('request', function(req, res) { | ||
res.end(); | ||
res.destroy(); | ||
res.socket.on('close', function() { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -393,0 +413,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65709
1450