{"record":{"id":"0cd20c43ca83a341","repo":"facebook/flow","slug":"flow-js-wasm-export-name-is-unavailable","errorCode":null,"errorMessage":"flow.js wasm export ${name} is unavailable","messagePattern":"flow\\.js wasm export (.+?) is unavailable","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/flow_dot_js_wasm.js","lineNumber":102,"sourceCode":"    }\n  }\n  if (typeof wasmExports === 'object' && wasmExports != null) {\n    if (typeof wasmExports[underscoredName] === 'function') {\n      return wasmExports[underscoredName];\n    }\n    if (typeof wasmExports[name] === 'function') {\n      return wasmExports[name];\n    }\n  }\n  return null;\n}\n\nfunction getWasmExport(wasmModule, name) {\n  const wasmExport = findWasmExport(wasmModule, name);\n  if (wasmExport != null) {\n    return wasmExport;\n  }\n  throw new Error(`flow.js wasm export ${name} is unavailable`);\n}\n\nfunction updateFlowDotJsMemoryViews() {\n  if (typeof updateMemoryViews === 'function') {\n    updateMemoryViews();\n  }\n}\n\nfunction prepareFlowDotJsFallbackStack() {\n  // The non-modular Buck/Emscripten output leaves the default 64KB stack.\n  if (\n    typeof wasmMemory !== 'object' ||\n    wasmMemory == null ||\n    typeof stackRestore !== 'function'\n  ) {\n    return;\n  }\n  updateFlowDotJsMemoryViews();","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/src/flow_dot_js_wasm.js#L84-L120","documentation":"Error from flow's flow.js WASM glue: before use, `getWasmExport` looks up required exports by name (with and without a leading underscore, e.g. `main`/`_main` for the dispatch entry point, plus flowDotJsAlloc/Free/StringFree/Call). If the installed WebAssembly module does not expose the expected function, the glue throws, meaning the .wasm binary does not match the JS glue that is driving it.","triggerScenarios":"Calling the flow wasm install/instantiation path with a WebAssembly.Module built from a different flow version's .wasm (version skew between glue JS and binary), a corrupted or truncated download, or a self-built wasm that did not export the required functions (missing EXPORTED_FUNCTIONS / modularize settings).","commonSituations":"Mixing a cached flow.js glue script with a newly downloaded flow.wasm (CDN/browser cache mismatch); partially upgrading flow packages so JS and wasm come from different releases; stripping/optimizing the wasm with tools that rename or drop exports.","solutions":["Make the .wasm binary and the JS glue come from the exact same flow version - reinstall/copy them together.","Clear browser/CDN caches (or cache-bust the URL) so both artifacts reload from one version.","Inspect `WebAssembly.Module.exports(module)` and confirm required names (`main`/`_main`, `flowDotJsAlloc`, etc.) are present before installing.","If self-building, export the required functions with the original (unminified) names via emscripten EXPORTED_FUNCTIONS."],"exampleFix":"// before - glue from v0.1, wasm from v0.2\ninstallWasmModule(compileFrom(mixedSource)); // -> wasm export main is unavailable\n\n// after - verify matching artifacts before install\nconst exports = WebAssembly.Module.exports(mod).map(e => e.name);\nif (!exports.includes('main') && !exports.includes('_main')) {\n  throw new Error('wasm binary does not match the flow.js glue - redownload both');\n}\ninstallWasmModule(mod);","handlingStrategy":"validation","validationCode":"function assertWasmExports(wasmModule, required = ['main']) {\n  const available = new Set(\n    WebAssembly.Module.exports(wasmModule).map(e => e.name),\n  );\n  for (const name of required) {\n    if (!available.has(name) && !available.has('_' + name)) {\n      throw new Error(\n        `wasm binary missing export '${name}' - glue/wasm version mismatch,` +\n        ' redownload both from the same flow version',\n      );\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  installWasmModule(mod);\n} catch (e) {\n  if (/wasm export .* is unavailable/.test(e.message)) {\n    // JS glue and .wasm are from different versions: clear caches,\n    // reinstall the matching pair, then retry once\n  } else throw e;\n}","preventionTips":["Ship/download flow.js glue and flow.wasm together from one release.","Cache-bust CDN URLs on upgrade so stale artifacts cannot mix.","Verify WebAssembly.Module.exports contains required names before installing.","When self-building wasm, keep original export names (EXPORTED_FUNCTIONS)."],"tags":["flow","wasm","version-mismatch","exports","module-loading"],"backgroundTag":"missing-wasm-export","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}