clockworklabs/SpacetimeDB · error · anyhow::Error

JS worker panicked during startup

Error message

JS worker panicked during startup

What it means

Module startup on the isolate thread is wrapped in catch_unwind; Err means Rust-level code in the v8 host (not a JS exception) panicked while evaluating builtins or the user module. The panic payload is not propagated, so callers only get 'JS worker panicked during startup'; the actual backtrace lives in host logs.

Solutions

  1. Check host logs/stderr for the panic backtrace - this message alone contains no cause.
  2. Upgrade the SpacetimeDB host and module SDK to pick up panic fixes.
  3. Reduce module size or complexity to rule out resource exhaustion.
  4. Reproduce with a minimal module and file a bug if it persists.
Defensive patterns

Strategy: retry

Try / catch

Treat as transient first: retry the publish/startup once with backoff; if it reproduces, capture host logs (the panic backtrace) and stop - a deterministic panic is a bug, not flakiness.

Prevention

When it happens

Trigger: A bug in the host's v8 glue panicking during startup; stack exhaustion or out-of-memory on the isolate thread; a panic while recreating the isolate after a previous crash.

Common situations: Host version bugs on specific platforms; extremely large modules hitting resource limits; repeated isolate restarts after an earlier failure.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-30). Data as JSON: /api/errors/db47fa58fe9d2021. Report an issue: GitHub.

Appendix: source

Thrown at crates/core/src/host/v8/mod.rs:1666

                    Either::Left(module) => (module.replica_ctx(), module.scheduler()),
                    Either::Right(mcc) => (&mcc.replica_ctx, &mcc.scheduler),
                };
                let instance_env = InstanceEnv::new(replica_ctx.clone(), scheduler.clone());
                scope.set_slot(JsInstanceEnv::new(instance_env));

                let startup_result = panic::catch_unwind(AssertUnwindSafe(|| {
                    catch_exception(scope, |scope| Ok(builtins::evaluate_builtins(scope)?))
                        .expect("our builtin code shouldn't error");

                    // Setup the JS module, find call_reducer, and maybe build the module.
                    startup_instance_worker(scope, program.clone(), generation_module_or_mcc)
                }));

                let (hooks, module_common) = match startup_result {
                    Err(_) => {
                        if let Some(result_tx) = startup_result_tx.take() {
                            if result_tx
                                .send(Err(anyhow::anyhow!("JS worker panicked during startup")))
                                .is_err()
                            {
                                log::warn!("startup result receiver disconnected");
                            }
                        } else {
                            log::error!("JS worker panicked while recreating isolate");
                        }
                        return;
                    }
                    Ok(Err(err)) => {
                        if let Some(result_tx) = startup_result_tx.take() {
                            if result_tx.send(Err(err)).is_err() {
                                log::warn!("startup result receiver disconnected");
                            }
                        } else {
                            log::error!("failed to restart JS worker: {err:#}");
                        }
                        return;

View on GitHub (pinned to eddf9f5014)