{"record":{"id":"db47fa58fe9d2021","repo":"clockworklabs/SpacetimeDB","slug":"js-worker-panicked-during-startup","errorCode":null,"errorMessage":"JS worker panicked during startup","messagePattern":"JS worker panicked during startup","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/v8/mod.rs","lineNumber":1666,"sourceCode":"                    Either::Left(module) => (module.replica_ctx(), module.scheduler()),\n                    Either::Right(mcc) => (&mcc.replica_ctx, &mcc.scheduler),\n                };\n                let instance_env = InstanceEnv::new(replica_ctx.clone(), scheduler.clone());\n                scope.set_slot(JsInstanceEnv::new(instance_env));\n\n                let startup_result = panic::catch_unwind(AssertUnwindSafe(|| {\n                    catch_exception(scope, |scope| Ok(builtins::evaluate_builtins(scope)?))\n                        .expect(\"our builtin code shouldn't error\");\n\n                    // Setup the JS module, find call_reducer, and maybe build the module.\n                    startup_instance_worker(scope, program.clone(), generation_module_or_mcc)\n                }));\n\n                let (hooks, module_common) = match startup_result {\n                    Err(_) => {\n                        if let Some(result_tx) = startup_result_tx.take() {\n                            if result_tx\n                                .send(Err(anyhow::anyhow!(\"JS worker panicked during startup\")))\n                                .is_err()\n                            {\n                                log::warn!(\"startup result receiver disconnected\");\n                            }\n                        } else {\n                            log::error!(\"JS worker panicked while recreating isolate\");\n                        }\n                        return;\n                    }\n                    Ok(Err(err)) => {\n                        if let Some(result_tx) = startup_result_tx.take() {\n                            if result_tx.send(Err(err)).is_err() {\n                                log::warn!(\"startup result receiver disconnected\");\n                            }\n                        } else {\n                            log::error!(\"failed to restart JS worker: {err:#}\");\n                        }\n                        return;","sourceCodeStart":1648,"sourceCodeEnd":1684,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/core/src/host/v8/mod.rs#L1648-L1684","documentation":"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.","triggerScenarios":"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.","commonSituations":"Host version bugs on specific platforms; extremely large modules hitting resource limits; repeated isolate restarts after an earlier failure.","solutions":["Check host logs/stderr for the panic backtrace - this message alone contains no cause.","Upgrade the SpacetimeDB host and module SDK to pick up panic fixes.","Reduce module size or complexity to rule out resource exhaustion.","Reproduce with a minimal module and file a bug if it persists."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Keep host and SDK versions aligned and current.","Monitor isolate restart counts.","Avoid gigantic single-file bundles; split module code."],"tags":["v8","isolate","panic","startup","internal"],"backgroundTag":"runtime-panic-during-startup","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-30T19:52:08.972Z","contentChangedAt":"2026-08-30T19:52:08.972Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}