denoland/deno · error

web workers are not supported

Error message

web workers are not supported

What it means

WorkerOptions::default() installs a create_web_worker_cb that is unimplemented!("web workers are not supported"). The default is only safe for runtimes that never spawn Web Workers; the first new Worker() in JS invokes the callback and panics.

Solutions

  1. Provide a create_web_worker_cb that builds a WebWorker with its own WebWorkerOptions (extensions, permissions, module loader)
  2. If workers are unsupported by design, fail fast at startup with your own error instead of relying on defaults
  3. Audit JS dependencies for Worker usage before shipping with default options

Example fix

// before
let options = WorkerOptions::default(); // new Worker() panics

// after
let options = WorkerOptions {
  create_web_worker_cb: Arc::new(|args| create_web_worker(args)),
  ..Default::default()
};
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Constructing a MainWorker from WorkerOptions::default() (or options that kept the default callback) and running JS that calls new Worker(url, { type: "module" }).

Common situations: Embedders wiring Deno into a host application; tests reusing default options; deployments that worked until a dependency started using Web Workers.

Related errors


AI-assisted analysis of denoland/deno@a961cdec3b (2026-08-20). Data as JSON: /api/errors/8898e4c02193c73c. Report an issue: GitHub.

Appendix: source

Thrown at runtime/worker.rs:322

  // user code.
  pub should_wait_for_inspector_session: bool,
  /// If Some, print a low-level trace output for ops matching the given patterns.
  pub trace_ops: Option<Vec<String>>,

  pub cache_storage_dir: Option<std::path::PathBuf>,
  pub origin_storage_dir: Option<std::path::PathBuf>,
  pub stdio: Stdio,
  pub enable_raw_imports: bool,
  pub enable_stack_trace_arg_in_ops: bool,

  pub unconfigured_runtime: Option<UnconfiguredRuntime>,
}

impl Default for WorkerOptions {
  fn default() -> Self {
    Self {
      create_web_worker_cb: Arc::new(|_| {
        unimplemented!("web workers are not supported")
      }),
      skip_op_registration: false,
      seed: None,
      unsafely_ignore_certificate_errors: Default::default(),
      should_break_on_first_statement: Default::default(),
      should_wait_for_inspector_session: Default::default(),
      trace_ops: Default::default(),
      format_js_error_fn: Default::default(),
      origin_storage_dir: Default::default(),
      cache_storage_dir: Default::default(),
      extensions: Default::default(),
      startup_snapshot: Default::default(),
      residual_lazy_js_sources: &[],
      residual_lazy_esm_sources: &[],
      create_params: Default::default(),
      bootstrap: Default::default(),
      stdio: Default::default(),
      enable_raw_imports: false,

View on GitHub (pinned to a961cdec3b)