| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fc57bea commit a9ce2b6
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,6 +133,7 @@ function pad(value) { | |||
| 133 | 133 | const kNone = 1 << 0; | |
| 134 | 134 | const kSkipLog = 1 << 1; | |
| 135 | 135 | const kSkipTrace = 1 << 2; | |
| 136 | + const kShouldSkipAll = kSkipLog | kSkipTrace; | ||
| 136 | 137 | ||
| 137 | 138 | const kSecond = 1000; | |
| 138 | 139 | const kMinute = 60 * kSecond; | |
@@ -377,8 +378,6 @@ function debugWithTimer(set, cb) { | |||
| 377 | 378 | let debugLogCategoryEnabled = false; | |
| 378 | 379 | let timerFlags = kNone; | |
| 379 | 380 | ||
| 380 | - const skipAll = kSkipLog | kSkipTrace; | ||
| 381 | - | ||
| 382 | 381 | function ensureTimerFlagsAreUpdated() { | |
| 383 | 382 | timerFlags &= ~kSkipTrace; | |
| 384 | 383 | ||
@@ -393,7 +392,7 @@ function debugWithTimer(set, cb) { | |||
| 393 | 392 | function internalStartTimer(logLabel, traceLabel) { | |
| 394 | 393 | ensureTimerFlagsAreUpdated(); | |
| 395 | 394 | ||
| 396 | - if (timerFlags === skipAll) { | ||
| 395 | + if ((timerFlags & kShouldSkipAll) === kShouldSkipAll) { | ||
| 397 | 396 | return; | |
| 398 | 397 | } | |
| 399 | 398 | ||
@@ -413,7 +412,7 @@ function debugWithTimer(set, cb) { | |||
| 413 | 412 | function internalEndTimer(logLabel, traceLabel) { | |
| 414 | 413 | ensureTimerFlagsAreUpdated(); | |
| 415 | 414 | ||
| 416 | - if (timerFlags === skipAll) { | ||
| 415 | + if ((timerFlags & kShouldSkipAll) === kShouldSkipAll) { | ||
| 417 | 416 | return; | |
| 418 | 417 | } | |
| 419 | 418 | ||
@@ -434,7 +433,7 @@ function debugWithTimer(set, cb) { | |||
| 434 | 433 | function internalLogTimer(logLabel, traceLabel, args) { | |
| 435 | 434 | ensureTimerFlagsAreUpdated(); | |
| 436 | 435 | ||
| 437 | - if (timerFlags === skipAll) { | ||
| 436 | + if ((timerFlags & kShouldSkipAll) === kShouldSkipAll) { | ||
| 438 | 437 | return; | |
| 439 | 438 | } | |
| 440 | 439 | ||
@@ -477,7 +476,7 @@ function debugWithTimer(set, cb) { | |||
| 477 | 476 | const startTimer = (logLabel, traceLabel) => { | |
| 478 | 477 | init(); | |
| 479 | 478 | ||
| 480 | - if (timerFlags !== skipAll) | ||
| 479 | + if ((timerFlags & kShouldSkipAll) !== kShouldSkipAll) | ||
| 481 | 480 | internalStartTimer(logLabel, traceLabel); | |
| 482 | 481 | }; | |
| 483 | 482 | ||
@@ -487,7 +486,7 @@ function debugWithTimer(set, cb) { | |||
| 487 | 486 | const endTimer = (logLabel, traceLabel) => { | |
| 488 | 487 | init(); | |
| 489 | 488 | ||
| 490 | - if (timerFlags !== skipAll) | ||
| 489 | + if ((timerFlags & kShouldSkipAll) !== kShouldSkipAll) | ||
| 491 | 490 | internalEndTimer(logLabel, traceLabel); | |
| 492 | 491 | }; | |
| 493 | 492 | ||
@@ -497,7 +496,7 @@ function debugWithTimer(set, cb) { | |||
| 497 | 496 | const logTimer = (logLabel, traceLabel, args) => { | |
| 498 | 497 | init(); | |
| 499 | 498 | ||
| 500 | - if (timerFlags !== skipAll) | ||
| 499 | + if ((timerFlags & kShouldSkipAll) !== kShouldSkipAll) | ||
| 501 | 500 | internalLogTimer(logLabel, traceLabel, args); | |
| 502 | 501 | }; | |
| 503 | 502 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + // dep1.js | ||
| 2 | + module.exports = function requireDep2() { | ||
| 3 | + require("./dep2.js"); | ||
| 4 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + // dep2.js | ||
| 2 | + | ||
| 3 | + // (empty) | ||
| Original file line number | Diff line number | Diff 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(); | ||
| Original file line number | Diff line number | Diff 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 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ import { readFile } from 'node:fs/promises'; | |||
| 4 | 4 | import { it } from 'node:test'; | |
| 5 | 5 | import tmpdir from '../common/tmpdir.js'; | |
| 6 | 6 | import { spawnSyncAndAssert } from '../common/child_process.js'; | |
| 7 | + import fixtures from '../common/fixtures.js'; | ||
| 7 | 8 | ||
| 8 | 9 | tmpdir.refresh(); | |
| 9 | 10 | ||
@@ -153,3 +154,19 @@ it('should support enable tracing dynamically', async () => { | |||
| 153 | 154 | const vmTraces = outputFileJson.filter((trace) => trace.name === "require('vm')"); | |
| 154 | 155 | assert.strictEqual(vmTraces.length, 0); | |
| 155 | 156 | }); | |
| 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 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments