{"record":{"id":"53ff35dcb3707336","repo":"ruvnet/ruflo","slug":"failed-to-load-wasm-module","errorCode":null,"errorMessage":"Failed to load WASM module","messagePattern":"Failed to load WASM module","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ruflo/src/ruvocal/src/lib/stores/wasmMcp.ts","lineNumber":84,"sourceCode":"// Request ID counter\nlet requestId = 0;\n\n/**\n * Initialize the WASM MCP server\n */\nexport async function initWasmMcp(): Promise<boolean> {\n\tif (!browser) return false;\n\n\tconst state = get(wasmMcpState);\n\tif (state.loaded || state.loading) return state.loaded;\n\n\twasmMcpState.update((s) => ({ ...s, loading: true, error: null }));\n\n\ttry {\n\t\t// Load WASM module\n\t\tconst wasm = await loadWasm();\n\t\tif (!wasm) {\n\t\t\tthrow new Error(\"Failed to load WASM module\");\n\t\t}\n\n\t\t// Create MCP server and gallery instances\n\t\tconst mcpServer = new wasm.WasmMcpServer();\n\t\tconst gallery = new wasm.WasmGallery();\n\n\t\t// Initialize the MCP server\n\t\tconst initResponse = callMcpInternal(mcpServer, \"initialize\", {\n\t\t\tprotocolVersion: \"2024-11-05\",\n\t\t\tclientInfo: { name: \"ruvocal-ui\", version: \"1.0.0\" },\n\t\t});\n\n\t\tif (initResponse.error) {\n\t\t\tthrow new Error(`MCP initialization failed: ${initResponse.error.message}`);\n\t\t}\n\n\t\t// Load persisted filesystem state from IndexedDB\n\t\tawait syncFromIndexedDB(mcpServer);","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/ruflo/src/ruvocal/src/lib/stores/wasmMcp.ts#L66-L102","documentation":"Thrown by initWasmMcp() when loadWasm() resolves to null. The browser-side MCP server is implemented as a WASM module (WasmMcpServer, WasmGallery); if the module cannot be fetched or instantiated, loadWasm swallows the cause and returns null, and this error surfaces instead. initWasmMcp guards with a loading flag, so concurrent calls don't retry — the failed state sticks until a fresh call after error reset.","triggerScenarios":"The WASM binary or its JS glue fails to load in the browser: 404 on the asset after a partial deploy or wrong `base` path, CSP blocking wasm-unsafe-eval, OutOfMemory during instantiation, or a browser with WebAssembly disabled/unsupported.","commonSituations":"Deploying under a sub-path where asset URLs for the .wasm file are wrong; strict Content-Security-Policy headers on the hosting layer; stale service worker serving an old HTML with new asset hashes; very old mobile browsers.","solutions":["Open the browser DevTools Network tab, reload, and find the failing .wasm request (status 404/403 or CSP console error).","404: redeploy so built assets and their hashes are consistent; verify the `base` path configuration matches the hosting prefix.","CSP: add 'wasm-unsafe-eval' to the script-src directive (and allow the asset origin).","Hard-refresh / unregister the service worker to clear stale asset references.","Confirm WebAssembly availability: typeof WebAssembly === 'object' in the console."],"exampleFix":"# CSP header (before)\nContent-Security-Policy: script-src 'self'\n\n# CSP header (after)\nContent-Security-Policy: script-src 'self' 'wasm-unsafe-eval'","handlingStrategy":"try-catch","validationCode":"if (typeof WebAssembly === \"undefined\") {\n\tthrow new Error(\"WebAssembly unavailable in this browser\");\n}","typeGuard":"function supportsWasm(): boolean {\n\ttry {\n\t\treturn typeof WebAssembly?.instantiate === \"function\";\n\t} catch {\n\t\treturn false;\n\t}\n}","tryCatchPattern":"try {\n\tconst ok = await initWasmMcp();\n\tif (!ok) disableMcpUi();\n} catch (err) {\n\t// state.error is set; show a retry button rather than leaving loading=true\n\tshowWasmErrorAndRetry(String(err));\n}","preventionTips":["Feature-detect WebAssembly before rendering MCP UI.","Ship consistent build artifacts (JS glue + .wasm) so loads never mix versions.","Allow 'wasm-unsafe-eval' in CSP and verify the .wasm asset returns 200 after deploys."],"tags":["wasm","browser","mcp","deployment"],"backgroundTag":"wasm-load-failure","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}