dotnet/BenchmarkDotNet · error · Error

Unable to determine application arguments for the current ru

Error message

Unable to determine application arguments for the current runtime.

What it means

The generated benchmark-main.mjs entry script could not find any engine-specific arguments array, so it cannot read the command-line arguments BenchmarkDotNet passes to the benchmark process.

Source

Thrown at src/BenchmarkDotNet/Templates/benchmark-main.mjs:44

    if (ENVIRONMENT_IS_NODE) {
        const argv = globalThis.process.argv ?? [];
        const sep = argv.indexOf("--");
        return sep >= 0 ? argv.slice(sep + 1) : argv.slice(2);
    }

    // v8/d8
    if (v8args !== undefined)
        return Array.from(v8args);

    // SpiderMonkey
    if (typeof scriptArgs !== "undefined")
        return Array.from(scriptArgs);

    // Windows Script Host / Chakra
    if (typeof WScript !== "undefined" && WScript.Arguments)
        return Array.from(WScript.Arguments);

    throw new Error("Unable to determine application arguments for the current runtime.");
}

const args = getAppArgs();

// Handle WebSocket capability probe
if (args.includes("--getSupportsWebSocket")) {
    let supportsWebSocket = false;

    // First check for native WebSocket support (browsers, some modern engines)
    if (typeof WebSocket !== "undefined") {
        supportsWebSocket = true;
    } else {
        // Try to import ws module (Node.js)
        try {
            await import("ws");
            supportsWebSocket = true;
        } catch (e) {
            // Neither native WebSocket nor ws module available

View on GitHub (pinned to b515068b61)

Solutions

  1. Run the benchmark script with a supported JavaScript engine: Node.js, v8/d8, SpiderMonkey, or Windows Script Host/Chakra.
  2. Pass arguments in the engine-specific way (process.argv for Node, arguments/v8args/scriptArgs/WScript.Arguments for the others).
  3. If you embedded the generated script in a custom host, expose the arguments via one of the recognized globals before the script runs.

When it happens

Trigger: Thrown at src/BenchmarkDotNet/Templates/benchmark-main.mjs:44 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13). Data as JSON: /api/errors/31e59ecb21bd13cd. Report an issue: GitHub.