Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5415911

Browse filesBrowse files
authored
fix: extract noop everywhere (#3559) (#3727)
1 parent fd32a55 commit 5415911
Copy full SHA for 5415911

File tree

2 files changed

+7
-3
lines changed
Filter options

2 files changed

+7
-3
lines changed

‎lib/dispatcher/client.js

Copy file name to clipboardExpand all lines: lib/dispatcher/client.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ let deprecatedInterceptorWarned = false
6363

6464
const kClosedResolve = Symbol('kClosedResolve')
6565

66+
const noop = () => {}
67+
6668
function getPipelining (client) {
6769
return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1
6870
}
@@ -442,7 +444,7 @@ async function connect (client) {
442444
})
443445

444446
if (client.destroyed) {
445-
util.destroy(socket.on('error', () => {}), new ClientDestroyedError())
447+
util.destroy(socket.on('error', noop), new ClientDestroyedError())
446448
return
447449
}
448450

@@ -453,7 +455,7 @@ async function connect (client) {
453455
? await connectH2(client, socket)
454456
: await connectH1(client, socket)
455457
} catch (err) {
456-
socket.destroy().on('error', () => {})
458+
socket.destroy().on('error', noop)
457459
throw err
458460
}
459461

‎lib/dispatcher/proxy-agent.js

Copy file name to clipboardExpand all lines: lib/dispatcher/proxy-agent.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ function defaultFactory (origin, opts) {
2323
return new Pool(origin, opts)
2424
}
2525

26+
const noop = () => {}
27+
2628
class ProxyAgent extends DispatcherBase {
2729
constructor (opts) {
2830
super()
@@ -81,7 +83,7 @@ class ProxyAgent extends DispatcherBase {
8183
servername: this[kProxyTls]?.servername || proxyHostname
8284
})
8385
if (statusCode !== 200) {
84-
socket.on('error', () => {}).destroy()
86+
socket.on('error', noop).destroy()
8587
callback(new RequestAbortedError(`Proxy response (${statusCode}) !== 200 when HTTP Tunneling`))
8688
}
8789
if (opts.protocol !== 'https:') {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.