summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-finished.js
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-08-30 12:13:58 +0200
committerMatteo Collina <hello@matteocollina.com>2019-09-02 16:31:33 +0200
commit897587c0132da5b50f54409422b91a935739edb9 (patch)
tree97e16c07e561d9dd3ce3a42d6dd7fe02ae47f48a /test/parallel/test-http-client-finished.js
parent94c944d0d57062401dd11eb108e7717b9dac62d2 (diff)
downloadandroid-node-v8-897587c0132da5b50f54409422b91a935739edb9.tar.gz
android-node-v8-897587c0132da5b50f54409422b91a935739edb9.tar.bz2
android-node-v8-897587c0132da5b50f54409422b91a935739edb9.zip
stream: don't deadlock on aborted stream
Not all streams (e.g. http.ClientRequest) will always emit 'close' after 'aborted'. PR-URL: https://github.com/nodejs/node/pull/29376 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/parallel/test-http-client-finished.js')
-rw-r--r--test/parallel/test-http-client-finished.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/parallel/test-http-client-finished.js b/test/parallel/test-http-client-finished.js
new file mode 100644
index 0000000000..2d7e5b95b3
--- /dev/null
+++ b/test/parallel/test-http-client-finished.js
@@ -0,0 +1,27 @@
+'use strict';
+const common = require('../common');
+const http = require('http');
+const { finished } = require('stream');
+
+{
+ // Test abort before finished.
+
+ const server = http.createServer(function(req, res) {
+ res.write('asd');
+ });
+
+ server.listen(0, common.mustCall(function() {
+ http.request({
+ port: this.address().port
+ })
+ .on('response', (res) => {
+ res.on('readable', () => {
+ res.destroy();
+ });
+ finished(res, common.mustCall(() => {
+ server.close();
+ }));
+ })
+ .end();
+ }));
+}