{"record":{"id":"0958e05beb001d1a","repo":"denoland/deno","slug":"benchcontext-end-has-already-been-invoked","errorCode":null,"errorMessage":"BenchContext::end() has already been invoked","messagePattern":"BenchContext::end\\(\\) has already been invoked","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cli/js/40_bench.js","lineNumber":446,"sourceCode":"          \"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) {\n        throw new TypeError(\"BenchContext::end() has already been invoked\");\n      }\n      currentBenchUserExplicitEnd = end;\n    },\n  };\n}\n\n/** Wrap a user benchmark function in one which returns a structured result. */\nfunction wrapBenchmark(desc) {\n  const fn = desc.fn;\n  return async function outerWrapped() {\n    let token = null;\n    const originalConsole = globalThis.console;\n    currentBenchId = desc.id;\n\n    try {\n      globalThis.console = new Console((s) => {\n        op_dispatch_bench_event({ output: s });\n      });","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/js/40_bench.js#L428-L464","documentation":"After verifying and extracting the archive into a sibling staging directory, the atomic rename into the cache location failed, and no concurrently-created valid copy (completion marker) exists at the destination, so cache population is reported failed rather than silently ignored.","triggerScenarios":"Filesystem errors on rename: destination held/locked by antivirus or file-sync clients, permission or ownership changes, exotic filesystem rename semantics, or a concurrent process that left the target in a bad state without the marker.","commonSituations":"Two `deno desktop` builds racing on a cold cache; OneDrive/Dropbox or AV scanning the cache dir; a read-only cache root; interrupted earlier runs.","solutions":["Delete the cache directory for that backend/target and re-run so it is re-downloaded and re-extracted cleanly","Exclude the Deno/lafney cache from antivirus and sync tools","Check and fix permissions/ownership on the cache root","Avoid simultaneous first-time desktop builds against the same cache, or retry after the other process finishes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure the cache root is writable and not synced/scanned before first download\nawait Deno.mkdir(cacheRoot, { recursive: true });\nawait Deno.writeFile(join(cacheRoot, '.probe'), new Uint8Array(1));\nawait Deno.remove(join(cacheRoot, '.probe'));","typeGuard":null,"tryCatchPattern":"try {\n  await populateLaufeyCache();\n} catch (e) {\n  if (!/atomic-rename/.test(String(e))) throw e;\n  await Deno.remove(cacheDir, { recursive: true }).catch(() => {}); // clear the mangled dir\n  await populateLaufeyCache(); // one clean retry re-downloads and re-extracts\n}","preventionTips":["Exclude the Deno/lafney cache from antivirus and cloud-sync tools","Serialize first-time desktop builds across machines sharing a cache","Keep the cache on a local filesystem, not a network mount"],"tags":["desktop","cache","filesystem","concurrency","laufey","rename"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}