| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b87c0d6 commit 4cdc5ea
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -818,13 +818,15 @@ function onSocketNT(req, socket, err) { | |||
| 818 | 818 | req.emit('close'); | |
| 819 | 819 | } | |
| 820 | 820 | ||
| 821 | - if (!err && req.agent) { | ||
| 822 | - socket?.emit('free'); | ||
| 823 | - } else if (socket) { | ||
| 824 | - finished(socket.destroy(err || req[kError]), (er) => { | ||
| 825 | - _destroy(req, er || err); | ||
| 826 | - }); | ||
| 827 | - return; | ||
| 821 | + if (socket) { | ||
| 822 | + if (!err && req.agent && !socket.destroyed) { | ||
| 823 | + socket.emit('free'); | ||
| 824 | + } else { | ||
| 825 | + finished(socket.destroy(err || req[kError]), (er) => { | ||
| 826 | + _destroy(req, er || err); | ||
| 827 | + }); | ||
| 828 | + return; | ||
| 829 | + } | ||
| 828 | 830 | } | |
| 829 | 831 | ||
| 830 | 832 | _destroy(req, err || req[kError]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const http = require('http'); | ||
| 5 | + const net = require('net'); | ||
| 6 | + | ||
| 7 | + function createConnection() { | ||
| 8 | + const socket = new net.Socket(); | ||
| 9 | + | ||
| 10 | + process.nextTick(function() { | ||
| 11 | + socket.destroy(new Error('Oops')); | ||
| 12 | + }); | ||
| 13 | + | ||
| 14 | + return socket; | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + { | ||
| 18 | + const req = http.get({ createConnection }); | ||
| 19 | + | ||
| 20 | + req.on('error', common.expectsError({ name: 'Error', message: 'Oops' })); | ||
| 21 | + req.abort(); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + { | ||
| 25 | + class CustomAgent extends http.Agent {} | ||
| 26 | + CustomAgent.prototype.createConnection = createConnection; | ||
| 27 | + | ||
| 28 | + const req = http.get({ agent: new CustomAgent() }); | ||
| 29 | + | ||
| 30 | + req.on('error', common.expectsError({ name: 'Error', message: 'Oops' })); | ||
| 31 | + req.abort(); | ||
| 32 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments