File tree 3 files changed +11
-5
lines changed
3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ const connectH2 = require('./client-h2.js')
60
60
61
61
const kClosedResolve = Symbol ( 'kClosedResolve' )
62
62
63
+ const noop = ( ) => { }
64
+
63
65
function getPipelining ( client ) {
64
66
return client [ kPipelining ] ?? client [ kHTTPContext ] ?. defaultPipelining ?? 1
65
67
}
@@ -418,7 +420,7 @@ async function connect (client) {
418
420
} )
419
421
420
422
if ( client . destroyed ) {
421
- util . destroy ( socket . on ( 'error' , ( ) => { } ) , new ClientDestroyedError ( ) )
423
+ util . destroy ( socket . on ( 'error' , noop ) , new ClientDestroyedError ( ) )
422
424
return
423
425
}
424
426
@@ -429,7 +431,7 @@ async function connect (client) {
429
431
? await connectH2 ( client , socket )
430
432
: await connectH1 ( client , socket )
431
433
} catch ( err ) {
432
- socket . destroy ( ) . on ( 'error' , ( ) => { } )
434
+ socket . destroy ( ) . on ( 'error' , noop )
433
435
throw err
434
436
}
435
437
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ function defaultFactory (origin, opts) {
23
23
return new Pool ( origin , opts )
24
24
}
25
25
26
+ const noop = ( ) => { }
27
+
26
28
class ProxyAgent extends DispatcherBase {
27
29
constructor ( opts ) {
28
30
if ( ! opts || ( typeof opts === 'object' && ! ( opts instanceof URL ) && ! opts . uri ) ) {
@@ -78,7 +80,7 @@ class ProxyAgent extends DispatcherBase {
78
80
servername : this [ kProxyTls ] ?. servername || proxyHostname
79
81
} )
80
82
if ( statusCode !== 200 ) {
81
- socket . on ( 'error' , ( ) => { } ) . destroy ( )
83
+ socket . on ( 'error' , noop ) . destroy ( )
82
84
callback ( new RequestAbortedError ( `Proxy response (${ statusCode } ) !== 200 when HTTP Tunneling` ) )
83
85
}
84
86
if ( opts . protocol !== 'https:' ) {
Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ const { webidl } = require('./webidl')
65
65
const { STATUS_CODES } = require ( 'node:http' )
66
66
const GET_OR_HEAD = [ 'GET' , 'HEAD' ]
67
67
68
+ const noop = ( ) => { }
69
+
68
70
const defaultUserAgent = typeof __UNDICI_IS_NODE__ !== 'undefined' || typeof esbuildDetection !== 'undefined'
69
71
? 'node'
70
72
: 'undici'
@@ -2164,8 +2166,8 @@ async function httpNetworkFetch (
2164
2166
statusText,
2165
2167
headersList,
2166
2168
body : decoders . length
2167
- ? pipeline ( this . body , ...decoders , ( ) => { } )
2168
- : this . body . on ( 'error' , ( ) => { } )
2169
+ ? pipeline ( this . body , ...decoders , noop )
2170
+ : this . body . on ( 'error' , noop )
2169
2171
} )
2170
2172
2171
2173
return true
You can’t perform that action at this time.
0 commit comments