{"record":{"id":"430c1a235429d62c","repo":"moeru-ai/airi","slug":"failed-to-ensure-mediapipe-wasm-assets-wasmoutp","errorCode":null,"errorMessage":"Failed to ensure MediaPipe WASM assets: ${wasmOutputDir} is empty","messagePattern":"Failed to ensure MediaPipe WASM assets: (.+?) is empty","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/model-driver-mediapipe/tasks/prepare-tasks.ts","lineNumber":99,"sourceCode":"await fs.mkdir(assetsRoot, { recursive: true })\n\nfor (const { key, source, outputPath } of taskTargets) {\n  if (await isUsableFile(outputPath)) {\n    console.log(`MediaPipe vision task asset for ${key} already exists at ${outputPath}, skipping download.`)\n    continue\n  }\n  await downloadAsset(key, source, outputPath)\n\n  if (!await isUsableFile(outputPath))\n    throw new Error(`Failed to ensure MediaPipe vision task asset for ${key}: missing or empty file at ${outputPath}`)\n}\n\nawait fs.mkdir(wasmOutputDir, { recursive: true })\nawait fs.cp(wasmSourceDir, wasmOutputDir, { recursive: true, force: true })\n\nconst wasmEntries = await fs.readdir(wasmOutputDir)\nif (!wasmEntries.length)\n  throw new Error(`Failed to ensure MediaPipe WASM assets: ${wasmOutputDir} is empty`)\n\nconsole.log('All MediaPipe vision task assets are prepared.')\n","sourceCodeStart":81,"sourceCodeEnd":102,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/model-driver-mediapipe/tasks/prepare-tasks.ts#L81-L102","documentation":"prepare-tasks.ts copies the WASM runtime from the installed @mediapipe/tasks-vision package (wasmSourceDir inside node_modules) into the package's public wasm output directory, then asserts the destination is non-empty. If readdir returns nothing, it throws this error: the copy produced no files, which in practice means the source WASM directory in node_modules was missing or empty before the copy even started.","triggerScenarios":"Running the prepare task when node_modules/@mediapipe/tasks-vision lacks its wasm subdirectory — interrupted/partial install, an aggressive pnpm store prune, a patched/overridden version of the package that ships no wasm files, or a wrong wasmSourceDir path after a package version bump changed the layout.","commonSituations":"Fresh clone where install was interrupted; CI cache of node_modules pruned mid-pipeline; pnpm overrides/patches pointing at a package variant without wasm assets; version upgrade of @mediapipe/tasks-vision that moved wasm files to a different folder than the script expects.","solutions":["Reinstall dependencies cleanly: remove node_modules (and the pnpm store entry if needed) and run pnpm install, then re-run the task.","Verify the source: list the wasm directory inside node_modules/@mediapipe/tasks-vision and confirm the .wasm/.js files exist; if not, the installed package is broken.","If you upgraded @mediapipe/tasks-vision, check whether its wasm path changed and update wasmSourceDir in tasks/prepare-tasks.ts accordingly.","As a stopgap, manually copy the wasm files into the printed wasmOutputDir and re-run — the script only asserts non-emptiness."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { readdir } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nconst require = createRequire(import.meta.url)\nconst wasmSource = require.resolve('@mediapipe/tasks-vision')\nconst entries = await readdir(join(dirname(wasmSource), 'wasm')).catch(() => [])\nif (!entries.length) {\n  // reinstall @mediapipe/tasks-vision before running the prepare task\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After upgrading @mediapipe/tasks-vision, confirm its wasm directory layout still matches wasmSourceDir in tasks/prepare-tasks.ts.","Avoid partial installs: reinstall dependencies cleanly when node_modules was pruned or an install was interrupted.","Cache node_modules or the wasm output dir on CI to avoid depending on every machine's install integrity."],"tags":["mediapipe","build","wasm","node-modules","dependencies"],"backgroundTag":"missing-dependency-files","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}