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 a9ce2b6

Browse filesBrowse files
H4adRafaelGSS
authored andcommitted
lib: fix emit warning for debuglog.time when disabled
PR-URL: #54275 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent fc57bea commit a9ce2b6
Copy full SHA for a9ce2b6

File tree

Expand file treeCollapse file tree

6 files changed

+50
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+50
-8
lines changed
Open diff view settings
Collapse file

‎lib/internal/util/debuglog.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/debuglog.js
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function pad(value) {
133133
const kNone = 1 << 0;
134134
const kSkipLog = 1 << 1;
135135
const kSkipTrace = 1 << 2;
136+
const kShouldSkipAll = kSkipLog | kSkipTrace;
136137

137138
const kSecond = 1000;
138139
const kMinute = 60 * kSecond;
@@ -377,8 +378,6 @@ function debugWithTimer(set, cb) {
377378
let debugLogCategoryEnabled = false;
378379
let timerFlags = kNone;
379380

380-
const skipAll = kSkipLog | kSkipTrace;
381-
382381
function ensureTimerFlagsAreUpdated() {
383382
timerFlags &= ~kSkipTrace;
384383

@@ -393,7 +392,7 @@ function debugWithTimer(set, cb) {
393392
function internalStartTimer(logLabel, traceLabel) {
394393
ensureTimerFlagsAreUpdated();
395394

396-
if (timerFlags === skipAll) {
395+
if ((timerFlags & kShouldSkipAll) === kShouldSkipAll) {
397396
return;
398397
}
399398

@@ -413,7 +412,7 @@ function debugWithTimer(set, cb) {
413412
function internalEndTimer(logLabel, traceLabel) {
414413
ensureTimerFlagsAreUpdated();
415414

416-
if (timerFlags === skipAll) {
415+
if ((timerFlags & kShouldSkipAll) === kShouldSkipAll) {
417416
return;
418417
}
419418

@@ -434,7 +433,7 @@ function debugWithTimer(set, cb) {
434433
function internalLogTimer(logLabel, traceLabel, args) {
435434
ensureTimerFlagsAreUpdated();
436435

437-
if (timerFlags === skipAll) {
436+
if ((timerFlags & kShouldSkipAll) === kShouldSkipAll) {
438437
return;
439438
}
440439

@@ -477,7 +476,7 @@ function debugWithTimer(set, cb) {
477476
const startTimer = (logLabel, traceLabel) => {
478477
init();
479478

480-
if (timerFlags !== skipAll)
479+
if ((timerFlags & kShouldSkipAll) !== kShouldSkipAll)
481480
internalStartTimer(logLabel, traceLabel);
482481
};
483482

@@ -487,7 +486,7 @@ function debugWithTimer(set, cb) {
487486
const endTimer = (logLabel, traceLabel) => {
488487
init();
489488

490-
if (timerFlags !== skipAll)
489+
if ((timerFlags & kShouldSkipAll) !== kShouldSkipAll)
491490
internalEndTimer(logLabel, traceLabel);
492491
};
493492

@@ -497,7 +496,7 @@ function debugWithTimer(set, cb) {
497496
const logTimer = (logLabel, traceLabel, args) => {
498497
init();
499498

500-
if (timerFlags !== skipAll)
499+
if ((timerFlags & kShouldSkipAll) !== kShouldSkipAll)
501500
internalLogTimer(logLabel, traceLabel, args);
502501
};
503502

Collapse file

‎test/fixtures/GH-54265/dep1.js‎

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// dep1.js
2+
module.exports = function requireDep2() {
3+
require("./dep2.js");
4+
};
Collapse file

‎test/fixtures/GH-54265/dep2.js‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// dep2.js
2+
3+
// (empty)
Collapse file

‎test/fixtures/GH-54265/index.js‎

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// index.js
2+
const Module = require("module");
3+
const requireDep2 = require("./dep1.js");
4+
5+
const globalCache = Module._cache;
6+
Module._cache = Object.create(null);
7+
require("./require-hook.js");
8+
Module._cache = globalCache;
9+
10+
requireDep2();
Collapse file
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// require-hook.js
2+
const Module = require("module");
3+
const requireDep2 = require("./dep1.js");
4+
5+
const originalJSLoader = Module._extensions[".js"];
6+
Module._extensions[".js"] = function customJSLoader(module, filename) {
7+
requireDep2();
8+
return originalJSLoader(module, filename);
9+
};
Collapse file

‎test/parallel/test-module-print-timing.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-module-print-timing.mjs
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { readFile } from 'node:fs/promises';
44
import { it } from 'node:test';
55
import tmpdir from '../common/tmpdir.js';
66
import { spawnSyncAndAssert } from '../common/child_process.js';
7+
import fixtures from '../common/fixtures.js';
78

89
tmpdir.refresh();
910

@@ -153,3 +154,19 @@ it('should support enable tracing dynamically', async () => {
153154
const vmTraces = outputFileJson.filter((trace) => trace.name === "require('vm')");
154155
assert.strictEqual(vmTraces.length, 0);
155156
});
157+
158+
it('should not print when is disabled and found duplicated labels (GH-54265)', () => {
159+
const testFile = fixtures.path('GH-54265/index.js');
160+
161+
spawnSyncAndAssert(process.execPath, [
162+
testFile,
163+
], {
164+
cwd: tmpdir.path,
165+
env: {
166+
...process.env,
167+
},
168+
}, {
169+
stdout: '',
170+
stderr: '',
171+
});
172+
});

0 commit comments

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