{"record":{"id":"53d16d74784e79a0","repo":"denoland/deno","slug":"unexpected-fn-field-in-options-bench-function-i-53d16d","errorCode":null,"errorMessage":"Unexpected 'fn' field in options, bench function is already provided as the second argument","messagePattern":"Unexpected 'fn' field in options, bench function is already provided as the second argument","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cli/js/40_bench.js","lineNumber":162,"sourceCode":"    }\n    if (optionsOrFn != undefined) {\n      throw new TypeError(\"Unexpected second argument to Deno.bench()\");\n    }\n    if (maybeFn != undefined) {\n      throw new TypeError(\"Unexpected third argument to Deno.bench()\");\n    }\n    benchDesc = {\n      ...defaults,\n      fn: nameOrFnOrOptions,\n      name: nameOrFnOrOptions.name,\n    };\n  } else {\n    let fn;\n    let name;\n    if (typeof optionsOrFn === \"function\") {\n      fn = optionsOrFn;\n      if (nameOrFnOrOptions.fn != undefined) {\n        throw new TypeError(\n          \"Unexpected 'fn' field in options, bench function is already provided as the second argument\",\n        );\n      }\n      name = nameOrFnOrOptions.name ?? fn.name;\n    } else {\n      if (\n        !nameOrFnOrOptions.fn || typeof nameOrFnOrOptions.fn !== \"function\"\n      ) {\n        throw new TypeError(\n          \"Expected 'fn' field in the first argument to be a bench function\",\n        );\n      }\n      fn = nameOrFnOrOptions.fn;\n      name = nameOrFnOrOptions.name ?? fn.name;\n    }\n    if (!name) {\n      throw new TypeError(\"The bench name can't be empty\");\n    }","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/js/40_bench.js#L144-L180","documentation":"In the compiled-binary global install flow, deno computes the output path (`<bin_dir>/<name>` or `<name>.exe` on Windows) and refuses to overwrite an existing file unless `--force`/`-f` is passed. Before recompiling it removes the old file so `deno compile`'s own overwrite-safety check (which guards against clobbering files it did not produce) does not fail; the removal error context even hints about running processes.","triggerScenarios":"`deno install -g <url>` when the target executable already exists on disk and no `-f` was given: a previous install of the same tool (same explicit `--name`, or same default name derived from the URL) is present.","commonSituations":"Re-running install to update a globally installed tool and forgetting `--force`; installing two different modules that resolve to the same output name.","solutions":["Re-run with `deno install -gf <url>` to overwrite the existing binary","Or uninstall first: `deno uninstall <name>` then install again","Or install under a different name: `deno install -g --name <other-name> <url>`","On Windows, if removal still fails, stop running instances of the tool (check Task Manager) first"],"exampleFix":"# before\n$ deno install -g https://example.com/cli.ts\n# Existing installation found. Aborting (Use -f to overwrite).\n\n# after\n$ deno install -gf https://example.com/cli.ts  # overwrites","handlingStrategy":"validation","validationCode":"# Update flow: make overwrite explicit instead of relying on absent state\nNAME=\"${NAME:-cli}\"  # name used at first install\nBIN=\"${DENO_INSTALL_ROOT:-$HOME/.deno}/bin/$NAME\"\n[ -f \"$BIN\" ] && deno uninstall \"$NAME\"\ndeno install -g --name \"$NAME\" \"$URL\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize tool-update scripts on `deno install -gf <url>`","Record the `--name` used at first install so updates target the same path deliberately","Treat the abort as intentional: never script blind overwrites of unknown files"],"tags":["install","force-overwrite","file-exists","global-install","compile"],"backgroundTag":"file-already-exists","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"}