denoland/deno · error · TypeError

Unexpected second argument to Deno.bench()

Error message

Unexpected second argument to Deno.bench()

What it means

macOS-only. In `--hmr` dev mode the icon is resolved to a single `.png`/`.icns` path passed to laufey via `LAUFEY_APP_ICON`; multi-size icon sets are only supported on the non-HMR build path, so an icon configured as a set aborts HMR startup.

Source

Thrown at cli/js/40_bench.js:146

      }
      if (optionsOrFn.name != undefined) {
        throw new TypeError(
          "Unexpected 'name' field in options, bench name is already provided as the first argument",
        );
      }
      benchDesc = {
        ...defaults,
        ...optionsOrFn,
        fn: maybeFn,
        name: nameOrFnOrOptions,
      };
    }
  } else if (typeof nameOrFnOrOptions === "function") {
    if (!nameOrFnOrOptions.name) {
      throw new TypeError("The bench function must have a name");
    }
    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",
        );

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Switch the config to a single icon path (one `.png` or `.icns`) for HMR sessions
  2. Or use the regular (non-HMR) build path when the full icon set is required

Example fix

// before
"icon": { "set": "icons/iconset/" }

// after
"icon": "icons/AppIcon.png"
Defensive patterns

Strategy: type-guard

Validate before calling

if ('set' in iconConfig) {
  throw new Error('icon sets unsupported in --hmr — configure a single icon for dev');
}

Type guard

type SingleIcon = { single: string } | string;
function isSingleIcon(icon: unknown): icon is SingleIcon {
  return typeof icon === 'string' ||
    (!!icon && typeof icon === 'object' && 'single' in icon && !('set' in icon));
}

Prevention

When it happens

Trigger: Running `deno desktop --hmr` on macOS with an `icon` configuration that declares a set (multiple sizes) instead of a single path.

Common situations: Reusing the production icon-set config unchanged while iterating in HMR dev mode; templates that default to icon sets.

Related errors


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/50b9b67d748fe51c. Report an issue: GitHub.