denoland/deno · warning

Warning: ${ArrayPrototypeJoin(unsupported, ", ")} option(s)

Error message

Warning: ${ArrayPrototypeJoin(unsupported, ", ")} option(s) are not supported for web Workers and will be ignored. Use the node:worker_threads module instead.

What it means

Deno's web Worker constructor (runtime/js/11_workers.js:117-131) warns when it sees env or workerData in the options object: those are node:worker_threads concepts that web Workers ignore. The worker still starts, but the options are dropped, so code relying on them reads undefined env/workerData inside the worker. The warning fires only when either option is present, even if the value is undefined-valued explicitly (options.env !== undefined).

Source

Thrown at runtime/js/11_workers.js:124

  // still be messages left to receive.
  #status = "RUNNING";

  constructor(specifier, options = { __proto__: null }) {
    super();
    specifier = String(specifier);
    const {
      deno,
      name,
      type = "classic",
    } = options;

    if (options.env !== undefined || options.workerData !== undefined) {
      const unsupported = [];
      if (options.env !== undefined) unsupported[unsupported.length] = "env";
      if (options.workerData !== undefined) {
        unsupported[unsupported.length] = "workerData";
      }
      globalThis.console.warn(
        `Warning: ${
          ArrayPrototypeJoin(unsupported, ", ")
        } option(s) are not supported ` +
          "for web Workers and will be ignored. Use the " +
          "node:worker_threads module instead.",
      );
    }

    const workerType = webidl.converters["WorkerType"](type);

    if (
      StringPrototypeStartsWith(specifier, "./") ||
      StringPrototypeStartsWith(specifier, "../") ||
      StringPrototypeStartsWith(specifier, "/") || workerType === "classic"
    ) {
      const baseUrl = getLocationHref();
      if (baseUrl != null) {
        specifier = new URL(specifier, baseUrl).href;

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Switch to node:worker_threads when you need env or workerData semantics: its Worker accepts these options natively in Deno
  2. Or keep the web Worker and pass per-worker data via postMessage; environment variables are inherited from the parent process automatically
  3. In cross-runtime code, detect the runtime (process.versions?.node vs Deno.version) and choose the right Worker/options pair
  4. If the options were accidental leftovers, delete them to silence the warning

Example fix

// before
const w = new Worker(new URL("./w.js", import.meta.url).href, {
  type: "module",
  workerData: { jobId: 42 }, // warned and ignored
});

// after
import { Worker } from "node:worker_threads";
const w = new Worker(new URL("./w.js", import.meta.url), {
  workerData: { jobId: 42 },
});
Defensive patterns

Strategy: validation

Validate before calling

// route node-style options to the implementation that supports them
const needsNode = opts.env !== undefined || opts.workerData !== undefined;
const { Worker } = needsNode
  ? await import("node:worker_threads")
  : { Worker: globalThis.Worker };
const w = new Worker(specifier, opts); // web options ignored safely only when absent

Type guard

function isWebWorkerSafe(o: Record<string, unknown>): boolean {
  return o.env === undefined && o.workerData === undefined;
}

Prevention

When it happens

Trigger: new Worker(specifier, { env: {...} }), new Worker(specifier, { workerData: {...} }), or both — any construction of the global web Worker with node:worker_threads-only options. Passing both produces a combined 'env, workerData' list; passing them to the node:worker_threads Worker instead works and never warns.

Common situations: Copy-pasting Node docs/examples that use worker_threads options while using the global Worker; cross-runtime libraries sharing worker code between Node and Deno; migrating Node scripts and expecting per-worker env overrides to apply.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/70a0a96373cf7232. Report an issue: GitHub.