Skip to content

Commit 3dee233

Browse files
committed
http: optimize debug function correctly
Exporting a variable that will be mutated later doesn't work. Refs: #37937 PR-URL: #37966 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 5c367e1 commit 3dee233

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

lib/_http_client.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const assert = require('internal/assert');
4646
const { once } = require('internal/util');
4747
const {
4848
_checkIsHttpToken: checkIsHttpToken,
49-
debug,
5049
freeParser,
5150
parsers,
5251
HTTPParser,
@@ -78,6 +77,10 @@ const {
7877

7978
const { addAbortSignal, finished } = require('stream');
8079

80+
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
81+
debug = fn;
82+
});
83+
8184
const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/;
8285
const kError = Symbol('kError');
8386

lib/_http_common.js

-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ module.exports = {
269269
chunkExpression: /(?:^|\W)chunked(?:$|\W)/i,
270270
continueExpression: /(?:^|\W)100-continue(?:$|\W)/i,
271271
CRLF: '\r\n',
272-
debug,
273272
freeParser,
274273
methods,
275274
parsers,

lib/_http_outgoing.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ const {
7979
const { validateString } = require('internal/validators');
8080
const { isUint8Array } = require('internal/util/types');
8181

82+
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
83+
debug = fn;
84+
});
85+
8286
const HIGH_WATER_MARK = getDefaultHighWaterMark();
83-
const { CRLF, debug } = common;
87+
const { CRLF } = common;
8488

8589
const kCorked = Symbol('corked');
8690

lib/_http_server.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const assert = require('internal/assert');
4545
const {
4646
parsers,
4747
freeParser,
48-
debug,
4948
CRLF,
5049
continueExpression,
5150
chunkExpression,
@@ -91,6 +90,10 @@ const {
9190
} = require('internal/dtrace');
9291
const { setTimeout, clearTimeout } = require('timers');
9392

93+
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
94+
debug = fn;
95+
});
96+
9497
const dc = require('diagnostics_channel');
9598
const onRequestStartChannel = dc.channel('http.server.request.start');
9699
const onResponseFinishChannel = dc.channel('http.server.response.finish');

0 commit comments

Comments
 (0)