{"record":{"id":"4eabd6d1ca0f13f6","repo":"perspective-dev/perspective","slug":"missing-perspective-server-wasm","errorCode":null,"errorMessage":"Missing perspective-server.wasm","messagePattern":"Missing perspective-server\\.wasm","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"rust/perspective-js/src/ts/perspective.browser.ts","lineNumber":330,"sourceCode":"\n    const viewer_class: any = customElements.get(\"perspective-viewer\");\n    if (viewer_class?.__wasm_client_module__) {\n        GLOBAL_CLIENT_MODULE = Promise.resolve(\n            viewer_class.__wasm_client_module__,\n        );\n        return GLOBAL_CLIENT_MODULE;\n    }\n\n    throw new Error(\n        \"perspective-js client wasm has not been compiled yet — call \" +\n            \"`init_client(...)` or `perspective.worker()` before \" +\n            \"`getCompiledClientWasm()`.\",\n    );\n}\n\nfunction get_server() {\n    if (SERVER_REGISTRY === undefined) {\n        throw new Error(\"Missing perspective-server.wasm\");\n    }\n\n    if (GLOBAL_SERVER_WASM === undefined) {\n        GLOBAL_SERVER_WASM = select_server_wasm(SERVER_REGISTRY);\n    }\n\n    return GLOBAL_SERVER_WASM.then((x) =>\n        x instanceof WebAssembly.Module ? x : x.slice(0),\n    );\n}\n\nlet GLOBAL_WORKER: undefined | (() => Promise<Worker>) = undefined;\n\n// `WorkerPlugin` resolves this import to a stub that exports\n// `getPerspectiveWorkerURL(): Promise<string>`. The URL is either a\n// Blob URL (inline mode — production builds) or a real file path\n// resolved against `import.meta.url` (file mode — debug builds).\n// Constructing the `Worker` lives here in the consumer rather than","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/perspective-dev/perspective/blob/11c8238c0c9c0b9e490b5a6a2dc277afad1e980a/rust/perspective-js/src/ts/perspective.browser.ts#L312-L348","documentation":"`get_server()` (used by `worker()`) materializes the server wasm that backs the Perspective engine in the Worker. It requires that `init_server()` was previously called to populate `SERVER_REGISTRY`; if not, there is no server wasm binary to select or download and it throws \"Missing perspective-server.wasm\".","triggerScenarios":"Calling `perspective.worker()` (the only caller) in a page where `perspective.init_server(...)` was never invoked — e.g. relying on a Node-style auto-load that doesn't exist in the browser build, or calling `worker()` before init.","commonSituations":"Upgrading perspective-js to a version that requires explicit `init_server()` registration in the browser; bundler not emitting/copying perspective-server.wasm so init code is skipped; calling `worker()` at module top level before the init call runs; forgetting the init call after refactoring bootstrap code.","solutions":["Call `perspective.init_server(fetch('perspective-server.wasm'))` before `perspective.worker()`.","For Memory64 hosts use the registration form: `init_server({ wasm32: () => fetch('perspective-server.wasm'), wasm64: () => fetch('perspective-server.memory64.wasm') })`.","Ensure the server wasm asset is emitted by your bundler and the fetch URL resolves (check network tab for 404s).","Order bootstrap so `init_server(...)` runs to completion before any `worker()` call."],"exampleFix":"// before\nconst worker = perspective.worker(); // throws: no server wasm registered\n// after\nperspective.init_server(fetch(\"perspective-server.wasm\"));\nconst worker = perspective.worker();","handlingStrategy":"try-catch","validationCode":"if (!serverInitialized) {\n  perspective.init_server(fetch(\"perspective-server.wasm\"));\n}\nconst worker = perspective.worker();","typeGuard":"function serverWasmRegistered(): boolean {\n  return serverInitialized; // set true immediately after init_server(...) succeeds\n}","tryCatchPattern":"try {\n  const worker = perspective.worker();\n} catch (e) {\n  if (String(e.message).includes(\"Missing perspective-server.wasm\")) {\n    perspective.init_server(fetch(\"perspective-server.wasm\"));\n    const worker = perspective.worker();\n  } else throw e;\n}","preventionTips":["Call `init_server(...)` once in app bootstrap before any `worker()` call.","Check that perspective-server.wasm is copied/emitted by your bundler and the URL 200s.","Keep init and worker creation in the same ordered async bootstrap.","Re-check init calls after upgrading perspective-js — newer versions require explicit registration in the browser."],"tags":["wasm","initialization","browser","worker"],"backgroundTag":"module-init-failed","analyzedSha":"11c8238c0c9c0b9e490b5a6a2dc277afad1e980a","analyzedAt":"2026-09-09T00:35:19.377Z","contentChangedAt":"2026-09-09T00:35:19.377Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}