Skip to content

Commit 0b8febf

Browse files
committed
chore: apply private symbol to onImmediateError and address linting errors
1 parent 793c722 commit 0b8febf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/_http_client.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
116116
const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/;
117117
const kError = Symbol('kError');
118118
const kImmediateError = Symbol('kImmediateError');
119+
const kOnImmediateError = Symbol('kOnImmediateError');
119120

120121
const kLenientAll = HTTPParser.kLenientAll | 0;
121122
const kLenientNone = HTTPParser.kLenientNone | 0;
@@ -899,7 +900,7 @@ function tickOnSocket(req, socket) {
899900
parser.joinDuplicateHeaders = req.joinDuplicateHeaders;
900901

901902
parser.onIncoming = parserOnIncomingClient;
902-
socket.removeListener('error', socket.onImmediateError);
903+
socket.removeListener('error', socket[kOnImmediateError]);
903904
socket.on('error', socketErrorListener);
904905
socket.on('data', socketOnData);
905906
socket.on('end', socketOnEnd);
@@ -942,10 +943,10 @@ ClientRequest.prototype.onSocket = function onSocket(socket, err) {
942943
const req = this;
943944

944945
if (!err && socket) {
945-
socket.onImmediateError = function onImmediateError(err) {
946+
socket[kOnImmediateError] = function onImmediateError(err) {
946947
req[kImmediateError] = err;
947948
}
948-
socket.on('error', socket.onImmediateError);
949+
socket.on('error', socket[kOnImmediateError]);
949950
}
950951

951952
process.nextTick(onSocketNT, this, socket, err);
@@ -968,7 +969,7 @@ function onSocketNT(req, socket, err) {
968969
}
969970

970971
if (socket) {
971-
socket.removeListener('error', socket.onImmediateError);
972+
socket.removeListener('error', socket[kOnImmediateError]);
972973
if (!err && req.agent && !socket.destroyed) {
973974
socket.emit('free');
974975
} else {

test/parallel/test-http-client-immediate-error.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ function agentFactory(handle, count) {
4747
return agent;
4848
};
4949

50-
const handleWithoutBind = callCount => ({
50+
const handleWithoutBind = (callCount) => ({
5151
connect: common.mustCall((req, addr, port) => {
5252
return UV_ENETUNREACH;
53-
}, callCount),
53+
}, callCount),
5454
readStart() { },
5555
close() { },
5656
});
5757

58-
const handleWithBind = callCount => ({
58+
const handleWithBind = (callCount) => ({
5959
readStart() { },
6060
close() { },
61-
bind: common.mustCall(() => UV_EADDRINUSE, callCount),
61+
bind: common.mustCall(() => UV_EADDRINUSE, callCount),
6262
});
6363

6464
const agentWithoutBind = agentFactory(handleWithoutBind(3), 3); // Because three tests will use this

0 commit comments

Comments
 (0)