Skip to content

Commit

Permalink
http: optimize debug function correctly
Browse files Browse the repository at this point in the history
Exporting a variable that will be mutated later doesn't work.

Refs: #37937

PR-URL: #37966
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
targos authored and MylesBorins committed Apr 4, 2021
1 parent a57dc06 commit d86aca9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const assert = require('internal/assert');
const { once } = require('internal/util');
const {
_checkIsHttpToken: checkIsHttpToken,
debug,
freeParser,
parsers,
HTTPParser,
Expand Down Expand Up @@ -79,6 +78,10 @@ const {

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

let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
debug = fn;
});

const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/;
const kError = Symbol('kError');

Expand Down
1 change: 0 additions & 1 deletion lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ module.exports = {
chunkExpression: /(?:^|\W)chunked(?:$|\W)/i,
continueExpression: /(?:^|\W)100-continue(?:$|\W)/i,
CRLF: '\r\n',
debug,
freeParser,
methods,
parsers,
Expand Down
6 changes: 5 additions & 1 deletion lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ const {
const { validateString } = require('internal/validators');
const { isUint8Array } = require('internal/util/types');

let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
debug = fn;
});

const HIGH_WATER_MARK = getDefaultHighWaterMark();
const { CRLF, debug } = common;
const { CRLF } = common;

const kCorked = Symbol('corked');

Expand Down
5 changes: 4 additions & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const assert = require('internal/assert');
const {
parsers,
freeParser,
debug,
CRLF,
continueExpression,
chunkExpression,
Expand Down Expand Up @@ -93,6 +92,10 @@ const { observerCounts, constants } = internalBinding('performance');
const { setTimeout, clearTimeout } = require('timers');
const { NODE_PERFORMANCE_ENTRY_TYPE_HTTP } = constants;

let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
debug = fn;
});

const dc = require('diagnostics_channel');
const onRequestStartChannel = dc.channel('http.server.request.start');
const onResponseFinishChannel = dc.channel('http.server.response.finish');
Expand Down

0 comments on commit d86aca9

Please sign in to comment.