Skip to content

Commit cfd2021

Browse files
http,https: give names to anonymous or misnamed functions
Affected functions: - http.OutgoingMessage.prototype.cork - http.OutgoingMessage.prototype.uncork - http.Server.prototype.close - http.Server.prototype.closeAllConnections - http.Server.prototype.closeIdleConnections - http.Server.prototype[Symbol.asyncDispose] - http.Server.prototype[nodejs.rejection] - http.validateHeaderName - http.validateHeaderValue - https.Server.prototype.closeAllConnections - https.Server.prototype.closeIdleConnections - https.Server.prototype.close PR-URL: #58180 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f56590e commit cfd2021

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

lib/_http_outgoing.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const {
7070
hideStackFrames,
7171
} = require('internal/errors');
7272
const { validateString } = require('internal/validators');
73+
const { assignFunctionName } = require('internal/util');
7374
const { isUint8Array } = require('internal/util/types');
7475

7576
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
@@ -254,14 +255,14 @@ OutgoingMessage.prototype._renderHeaders = function _renderHeaders() {
254255
return headers;
255256
};
256257

257-
OutgoingMessage.prototype.cork = function() {
258+
OutgoingMessage.prototype.cork = function cork() {
258259
this[kCorked]++;
259260
if (this[kSocket]) {
260261
this[kSocket].cork();
261262
}
262263
};
263264

264-
OutgoingMessage.prototype.uncork = function() {
265+
OutgoingMessage.prototype.uncork = function uncork() {
265266
this[kCorked]--;
266267
if (this[kSocket]) {
267268
this[kSocket].uncork();
@@ -606,21 +607,21 @@ function matchHeader(self, state, field, value) {
606607
}
607608
}
608609

609-
const validateHeaderName = hideStackFrames((name, label) => {
610+
const validateHeaderName = assignFunctionName('validateHeaderName', hideStackFrames((name, label) => {
610611
if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) {
611612
throw new ERR_INVALID_HTTP_TOKEN.HideStackFramesError(label || 'Header name', name);
612613
}
613-
});
614+
}));
614615

615-
const validateHeaderValue = hideStackFrames((name, value) => {
616+
const validateHeaderValue = assignFunctionName('validateHeaderValue', hideStackFrames((name, value) => {
616617
if (value === undefined) {
617618
throw new ERR_HTTP_INVALID_HEADER_VALUE.HideStackFramesError(value, name);
618619
}
619620
if (checkInvalidHeaderChar(value)) {
620621
debug('Header "%s" contains invalid characters', name);
621622
throw new ERR_INVALID_CHAR.HideStackFramesError('header content', name);
622623
}
623-
});
624+
}));
624625

625626
function parseUniqueHeadersOption(headers) {
626627
if (!ArrayIsArray(headers)) {

lib/_http_server.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const {
8080
},
8181
} = require('internal/errors');
8282
const {
83+
assignFunctionName,
8384
kEmptyObject,
8485
promisify,
8586
} = require('internal/util');
@@ -573,17 +574,17 @@ function Server(options, requestListener) {
573574
ObjectSetPrototypeOf(Server.prototype, net.Server.prototype);
574575
ObjectSetPrototypeOf(Server, net.Server);
575576

576-
Server.prototype.close = function() {
577+
Server.prototype.close = function close() {
577578
httpServerPreClose(this);
578579
ReflectApply(net.Server.prototype.close, this, arguments);
579580
return this;
580581
};
581582

582-
Server.prototype[SymbolAsyncDispose] = async function() {
583+
Server.prototype[SymbolAsyncDispose] = assignFunctionName(SymbolAsyncDispose, async function() {
583584
return promisify(this.close).call(this);
584-
};
585+
});
585586

586-
Server.prototype.closeAllConnections = function() {
587+
Server.prototype.closeAllConnections = function closeAllConnections() {
587588
if (!this[kConnections]) {
588589
return;
589590
}
@@ -595,7 +596,7 @@ Server.prototype.closeAllConnections = function() {
595596
}
596597
};
597598

598-
Server.prototype.closeIdleConnections = function() {
599+
Server.prototype.closeIdleConnections = function closeIdleConnections() {
599600
if (!this[kConnections]) {
600601
return;
601602
}
@@ -618,7 +619,8 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) {
618619
return this;
619620
};
620621

621-
Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) {
622+
Server.prototype[EE.captureRejectionSymbol] =
623+
assignFunctionName(EE.captureRejectionSymbol, function(err, event, ...args) {
622624
switch (event) {
623625
case 'request': {
624626
const { 1: res } = args;
@@ -639,7 +641,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) {
639641
net.Server.prototype[SymbolFor('nodejs.rejection')]
640642
.apply(this, arguments);
641643
}
642-
};
644+
});
643645

644646
function checkConnections() {
645647
if (this.headersTimeout === 0 && this.requestTimeout === 0) {

lib/https.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Server.prototype.closeIdleConnections = HttpServer.prototype.closeIdleConnection
110110

111111
Server.prototype.setTimeout = HttpServer.prototype.setTimeout;
112112

113-
Server.prototype.close = function() {
113+
Server.prototype.close = function close() {
114114
httpServerPreClose(this);
115115
ReflectApply(tls.Server.prototype.close, this, arguments);
116116
return this;

0 commit comments

Comments
 (0)