denoland/deno · error · TypeError
Unexpected 'fn' field in options, bench function is already
Error message
Unexpected 'fn' field in options, bench function is already provided as the second argument
What it means
The desktop icon file exists but its extension is neither `.icns` nor `.png` — the only formats accepted by the laufey `NSImage initWithContentsOfFile:` path used here, so no conversion is attempted and startup aborts.
Source
Thrown at cli/js/40_bench.js:162
}
if (optionsOrFn != undefined) {
throw new TypeError("Unexpected second argument to Deno.bench()");
}
if (maybeFn != undefined) {
throw new TypeError("Unexpected third argument to Deno.bench()");
}
benchDesc = {
...defaults,
fn: nameOrFnOrOptions,
name: nameOrFnOrOptions.name,
};
} else {
let fn;
let name;
if (typeof optionsOrFn === "function") {
fn = optionsOrFn;
if (nameOrFnOrOptions.fn != undefined) {
throw new TypeError(
"Unexpected 'fn' field in options, bench function is already provided as the second argument",
);
}
name = nameOrFnOrOptions.name ?? fn.name;
} else {
if (
!nameOrFnOrOptions.fn || typeof nameOrFnOrOptions.fn !== "function"
) {
throw new TypeError(
"Expected 'fn' field in the first argument to be a bench function",
);
}
fn = nameOrFnOrOptions.fn;
name = nameOrFnOrOptions.name ?? fn.name;
}
if (!name) {
throw new TypeError("The bench name can't be empty");
}View on GitHub (pinned to 89f33cbef2)
Solutions
- Convert the image to PNG, e.g. `magick assets/logo.svg assets/logo.png`
- Or convert to `.icns` if you want the macOS native format
- Point the `icon` config at the converted `.png`/`.icns` file
Example fix
// before "icon": "assets/logo.svg" // after // $ magick assets/logo.svg assets/logo.png "icon": "assets/logo.png"
Defensive patterns
Strategy: validation
Validate before calling
const ext = iconPath.split('.').pop()?.toLowerCase();
if (ext !== 'png' && ext !== 'icns') {
throw new Error(`icon must be .png or .icns, got .${ext}`);
} Type guard
function isSupportedIcon(p: string): boolean {
return /\.(png|icns)$/i.test(p);
} Prevention
- Convert all brand assets to PNG/ICNS during the asset pipeline, not at app launch
- Add a lint rule on the desktop config restricting icon extensions
When it happens
Trigger: Passing `.jpg`, `.jpeg`, `.svg`, `.ico`, `.webp`, or an extensionless file as the desktop icon on macOS.
Common situations: Reusing a web favicon (.ico/.svg), marketing photo (.jpg), or design-tool export (.webp) as the app icon.
Related errors
- Unexpected second argument to Deno.bench()
- Unexpected 'name' field in options, bench name is already pr
- Unexpected third argument to Deno.bench()
- Either `node` or `range` must be provided when reporting an
- Invalid range. Start value is bigger than end value: [${star
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/53d16d74784e79a0.
Report an issue: GitHub.