{"record":{"id":"9f892ef2ec47cfef","repo":"denoland/deno","slug":"benchcontext-start-has-already-been-invoked","errorCode":null,"errorMessage":"BenchContext::start() has already been invoked","messagePattern":"BenchContext::start\\(\\) has already been invoked","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cli/js/40_bench.js","lineNumber":432,"sourceCode":"    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) {\n        throw new TypeError(\"BenchContext::end() has already been invoked\");\n      }\n      currentBenchUserExplicitEnd = end;\n    },\n  };","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/js/40_bench.js#L414-L450","documentation":"Every executable name — whether given via `--name` or inferred from the module URL / package bin map — must match `^[a-z0-9][\\w-]*$` (case-insensitive). That means: starts with an ASCII letter or digit, followed only by letters, digits, underscore, or hyphen. `validate_name` runs after inference, so even a successfully inferred name can be rejected if it contains characters like spaces or slashes.","triggerScenarios":"`deno install -g --name 'my tool' <url>` (space), `--name '-foo'` (leading dash), `--name '@scope/tool'` or `--name 'a/b'` (slash), or a URL-derived name containing invalid characters (e.g. a directory segment with a space, like the inference of `https://example.com/ab%20c/mod.ts` to `ab c`).","commonSituations":"Trying to keep npm-style scoped names (`@scope/pkg`) as bin names; copy-pasting display names with spaces; URL directory segments that contain encoded spaces or other non-word characters.","solutions":["Choose a name matching `[a-zA-Z0-9][a-zA-Z0-9_-]*`, e.g. `--name my-tool`","Strip scopes/slashes/spaces before passing `--name`","For scoped packages, let inference use the package's bin entry, or pass an explicit flat name"],"exampleFix":"# before\n$ deno install -g --name \"@scope/tool\" https://example.com/x.ts\n# Invalid executable name: @scope/tool\n\n# after\n$ deno install -g --name scope-tool https://example.com/x.ts","handlingStrategy":"type-guard","validationCode":"// Validate a chosen bin name the same way deno does\nconst VALID = /^[a-z0-9][\\w-]*$/i;\nexport const isValidExecName = (n: string) => VALID.test(n);","typeGuard":"function isValidExecName(name: string): boolean {\n  return /^[a-z0-9][\\w-]*$/i.test(name);\n}","tryCatchPattern":null,"preventionTips":["Prefer flat, kebab-case names (`my-tool`) for `--name`","Strip scopes and slashes from npm-style names before passing them to install","Validate names in wrapper UIs with the same regex so users get feedback before deno runs"],"tags":["install","naming","validation","regex"],"backgroundTag":"invalid-name-format","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"}