+24
-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 |
+1
-1
| { | ||
| "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", |
+20
-0
@@ -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 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
65709
2.08%1450
2.62%