{"record":{"id":"2e4264999af6ed48","repo":"denoland/deno","slug":"the-benchmark-which-this-context-belongs-to-is-not","errorCode":null,"errorMessage":"The benchmark which this context belongs to is not being executed","messagePattern":"The benchmark which this context belongs to is not being executed","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cli/js/40_bench.js","lineNumber":427,"sourceCode":"    wavg > lowPrecisionThresholdInNs,\n    usedExplicitTimers,\n    avg,\n    min,\n    max,\n    allSlice,\n    allLength,\n  );\n}\n\n/** @param desc {BenchDescription} */\nfunction createBenchContext(desc) {\n  return {\n    [SymbolToStringTag]: \"BenchContext\",\n    name: desc.name,\n    origin: desc.origin,\n    start() {\n      if (currentBenchId !== desc.id) {\n        throw new TypeError(\n          \"The benchmark which this context belongs to is not being executed\",\n        );\n      }\n      if (currentBenchUserExplicitStart != null) {\n        throw new TypeError(\n          \"BenchContext::start() has already been invoked\",\n        );\n      }\n      currentBenchUserExplicitStart = benchNow();\n    },\n    end() {\n      const end = benchNow();\n      if (currentBenchId !== desc.id) {\n        throw new TypeError(\n          \"The benchmark which this context belongs to is not being executed\",\n        );\n      }\n      if (currentBenchUserExplicitEnd != null) {","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/js/40_bench.js#L409-L445","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before (embedder code)\nlet flags = Flags { log_level: Some(log::Level::Warn), ..Default::default() };\n// -> invalid log level Warn when installing\n\n// after\nlet flags = Flags { log_level: Some(log::Level::Info), ..Default::default() };","handlingStrategy":"validation","validationCode":"// Embedders: normalize the level before building Flags\nfn shim_safe_level(l: Option<log::Level>) -> Option<log::Level> {\n  match l {\n    Some(log::Level::Debug) | Some(log::Level::Info) | Some(log::Level::Error) => l,\n    _ => None, // Warn/Trace have no shim mapping\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["install","logging","internal-invariant","shim"],"backgroundTag":"invalid-log-level","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}