denoland/deno · error · TypeError
The benchmark which this context belongs to is not being…
Error message
The benchmark which this context belongs to is not being executed
What it means
When deno writes the launcher shim for a global install, it embeds the current log level into the shim's deno invocation. Only three levels map onto CLI flags: Error becomes `--quiet`, Debug becomes `--log-level debug`, Info becomes `--log-level info`. Any other `log::Level` (Warn, Trace) has no shim equivalent, so the match is exhaustive-with-error by design — the comment notes this prevents silent gaps if the flag ever grows new levels.
Solutions
- Set `log_level` to `Some(Level::Debug)`/`Some(Level::Info)` or `None` before invoking install
- If you need quieter shims, use `Some(Level::Error)` which maps to `--quiet`
- If you hit this from the plain CLI on a recent deno, update deno — the mapping and the flag set must agree
Example fix
// before (embedder code)
let flags = Flags { log_level: Some(log::Level::Warn), ..Default::default() };
// -> invalid log level Warn when installing
// after
let flags = Flags { log_level: Some(log::Level::Info), ..Default::default() }; Defensive patterns
Strategy: validation
Validate before calling
// Embedders: normalize the level before building Flags
fn shim_safe_level(l: Option<log::Level>) -> Option<log::Level> {
match l {
Some(log::Level::Debug) | Some(log::Level::Info) | Some(log::Level::Error) => l,
_ => None, // Warn/Trace have no shim mapping
}
} Prevention
- When driving deno programmatically, restrict log_level to Error/Debug/Info or None
- Add a unit test over all log::Level variants whenever you build install Flags
- On CLI, prefer --quiet (Error) or --log-level debug/info only
When it happens
Trigger: Global install (`deno install -g ...`) with `flags.log_level` set to a Level other than Error/Debug/Info. The stock CLI does not expose warn/trace on `--log-level`, so this mainly fires for embedders building `Flags` programmatically (deno_lib consumers, custom tools) or after a future flag addition that lacks a shim mapping.
Common situations: A wrapper application constructing deno `Flags` with `log_level: Some(Level::Warn)`; deno-internal version drift where a new accepted log level reaches the shim generator unmapped (this guard turns that into a loud error instead of wrong log output).
Related errors
- Expected 'fn' field in the first argument to be a bench…
- Unexpected third argument to Deno.bench()
- BenchContext::end() has already been invoked
- BenchContext::start() has already been invoked
- deno ci requires a lockfile, but none was found. hint…
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/2e4264999af6ed48.
Report an issue: GitHub.
Appendix: source
Thrown at cli/js/40_bench.js:427
wavg > lowPrecisionThresholdInNs,
usedExplicitTimers,
avg,
min,
max,
allSlice,
allLength,
);
}
/** @param desc {BenchDescription} */
function createBenchContext(desc) {
return {
[SymbolToStringTag]: "BenchContext",
name: desc.name,
origin: desc.origin,
start() {
if (currentBenchId !== desc.id) {
throw new TypeError(
"The benchmark which this context belongs to is not being executed",
);
}
if (currentBenchUserExplicitStart != null) {
throw new TypeError(
"BenchContext::start() has already been invoked",
);
}
currentBenchUserExplicitStart = benchNow();
},
end() {
const end = benchNow();
if (currentBenchId !== desc.id) {
throw new TypeError(
"The benchmark which this context belongs to is not being executed",
);
}
if (currentBenchUserExplicitEnd != null) {View on GitHub (pinned to 9ad36f7a2c)