{"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/27111382b4a79a7e983289d6e983a06af185ed0f/packages/model-driver-mediapipe/tasks/prepare-tasks.ts#L81-L102","documentation":"Thrown by prepare-tasks.ts when, after fs.mkdir and fs.cp of the @mediapipe/tasks-vision/wasm directory into tasks/assets/wasm, the destination readdir returns an empty array. The WASM files are required at runtime by FilesetResolver.forVisionTasks, so an empty copy means the backend cannot initialize.","triggerScenarios":"fs.cp(wasmSourceDir, wasmOutputDir, { recursive: true, force: true }) silently copied nothing because wasmSourceDir was empty or missing; node_modules/@mediapipe/tasks-vision/wasm was pruned by a monorepo hoist or not populated because @mediapipe/tasks-vision is not installed at the expected location.","commonSituations":"pnpm hoisting moved the wasm dir elsewhere; a pruned/lite install omitted optional files; the tasks-vision package version changed its layout; the cp target was cleared by a clean step between cp and readdir; building from a tarball where node_modules is incomplete.","solutions":["Verify packages/model-driver-mediapipe/node_modules/@mediapipe/tasks-vision/wasm exists and contains .wasm files.","Reinstall dependencies: pnpm install --force in the package, then rerun prepare-assets.","If the wasm dir is hoisted, adjust the wasmSourceDir resolution or pin @mediapipe/tasks-vision as a direct dependency.","Avoid running clean steps that wipe tasks/assets between cp and the readdir check."],"exampleFix":"# before\nls node_modules/@mediapipe/tasks-vision/wasm  # empty\n# after\npnpm -F @proj-airi/model-driver-mediapipe install --force\nls node_modules/@mediapipe/tasks-vision/wasm  # vision_packed_assets_loader.js, *.wasm ...\npnpm -F @proj-airi/model-driver-mediapipe prepare-assets","handlingStrategy":"validation","validationCode":"import { readdir } from 'node:fs/promises'\nimport { existsSync } from 'node:fs'\n\nconst wasmSrc = 'node_modules/@mediapipe/tasks-vision/wasm'\nif (!existsSync(wasmSrc) || (await readdir(wasmSrc)).length === 0) {\n  throw new Error('@mediapipe/tasks-vision wasm dir missing; run pnpm install --force')\n}","typeGuard":null,"tryCatchPattern":"try {\n  await import('./prepare-tasks')\n} catch (error) {\n  if (error instanceof Error && /WASM assets.*is empty/.test(error.message)) {\n    // reinstall the dependency and rerun prepare-assets\n  } else throw error\n}","preventionTips":["Pin @mediapipe/tasks-vision as a direct dependency to avoid hoist loss.","Verify node_modules/@mediapipe/tasks-vision/wasm is populated in CI smoke steps.","Avoid clean steps that wipe tasks/assets between cp and the readdir check."],"tags":["mediapipe","build","wasm","assets","dependency-resolution"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}