Skip to content

Commit 2c3258d

Browse files
sheplupenalosapetebacondarwin
authored
Reduce @cloudflare/vitest-pool-workers log noise (#13007)
Co-authored-by: Samuel Macleod <smacleod@cloudflare.com> Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
1 parent d090818 commit 2c3258d

2 files changed

Lines changed: 28 additions & 18 deletions

File tree

.changeset/vpw-log-level.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@cloudflare/vitest-pool-workers": patch
3+
---
4+
5+
Reduce default log verbosity from `VERBOSE` to `INFO`
6+
7+
The pool logger was previously hardcoded to `VERBOSE`, causing noisy debug messages on every test run (e.g. `[vpw:debug] Adding compatibility flag...`). Only informational, warning, and error messages are now printed by default.
8+
9+
For debugging, set `NODE_DEBUG=vitest-pool-workers` to restore the detailed output.

packages/vitest-pool-workers/src/pool/index.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
33
import fs from "node:fs";
44
import path from "node:path";
55
import { fileURLToPath } from "node:url";
6+
import util from "node:util";
67
import { getTodaysCompatDate } from "@cloudflare/workers-utils";
78
import * as devalue from "devalue";
89
import getPort, { portNumbers } from "get-port";
@@ -66,8 +67,10 @@ export function structuredSerializableParse(value: string): unknown {
6667
return devalue.parse(value, structuredSerializableRevivers);
6768
}
6869

69-
// Log for informational pool messages
70-
const log = new Log(LogLevel.VERBOSE, { prefix: "vpw" });
70+
// Log for pool info/warnings/errors (user-actionable messages only)
71+
const log = new Log(LogLevel.INFO, { prefix: "vpw" });
72+
// Debug log gated behind NODE_DEBUG=vitest-pool-workers
73+
const debug = util.debuglog("vitest-pool-workers");
7174
// Log for Miniflare instances, used for user code warnings/errors
7275
const mfLog = new Log(LogLevel.WARN);
7376

@@ -312,10 +315,10 @@ async function buildProjectWorkerOptions(
312315
if (runnerWorker.compatibilityDate === undefined) {
313316
// No compatibility date was provided, so use today's date
314317
runnerWorker.compatibilityDate = getTodaysCompatDate();
315-
log.info(
316-
`No compatibility date was provided for project ${getRelativeProjectPath(
317-
project
318-
)}, defaulting to today's date ${runnerWorker.compatibilityDate}.`
318+
debug(
319+
"No compatibility date was provided for project %s, defaulting to today's date %s.",
320+
getRelativeProjectPath(project),
321+
runnerWorker.compatibilityDate
319322
);
320323
}
321324

@@ -659,15 +662,12 @@ export async function getProjectMiniflare(
659662
poolOptions,
660663
main
661664
);
662-
log.info(
663-
`Starting runtime for ${getRelativeProjectPath(project)}` +
664-
`${
665-
mfOptions.inspectorPort !== undefined
666-
? ` with inspector on port ${mfOptions.inspectorPort}`
667-
: ""
668-
}` +
669-
`...`
670-
);
665+
debug("Starting runtime for %s...", getRelativeProjectPath(project));
666+
if (mfOptions.inspectorPort !== undefined) {
667+
log.info(
668+
`Starting inspector on port ${mfOptions.inspectorPort} for ${getRelativeProjectPath(project)}`
669+
);
670+
}
671671
const mf = new Miniflare(mfOptions);
672672
await mf.ready;
673673
return mf;
@@ -812,13 +812,14 @@ function ensureFeature(compatibilityFlags: string[], feature: string) {
812812
const flagToEnable = `enable_${feature}`;
813813
const flagToDisable = `disable_${feature}`;
814814
if (!compatibilityFlags.includes(flagToEnable)) {
815-
log.debug(
816-
`Adding \`${flagToEnable}\` compatibility flag during tests as this feature is needed to support the Vitest runner.`
815+
debug(
816+
"Adding `%s` compatibility flag during tests as this feature is needed to support the Vitest runner.",
817+
flagToEnable
817818
);
818819
compatibilityFlags.push(flagToEnable);
819820
}
820821
if (compatibilityFlags.includes(flagToDisable)) {
821-
log.info(
822+
log.warn(
822823
`Removing \`${flagToDisable}\` compatibility flag during tests as that feature is needed to support the Vitest runner.`
823824
);
824825
compatibilityFlags.splice(compatibilityFlags.indexOf(flagToDisable), 1);

0 commit comments

Comments
 (0)