moeru-ai/airi · error · Error
Failed to ensure MediaPipe WASM assets: ${wasmOutputDir} is
Error message
Failed to ensure MediaPipe WASM assets: ${wasmOutputDir} is empty What it means
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.
Source
Thrown at packages/model-driver-mediapipe/tasks/prepare-tasks.ts:99
await fs.mkdir(assetsRoot, { recursive: true })
for (const { key, source, outputPath } of taskTargets) {
if (await isUsableFile(outputPath)) {
console.log(`MediaPipe vision task asset for ${key} already exists at ${outputPath}, skipping download.`)
continue
}
await downloadAsset(key, source, outputPath)
if (!await isUsableFile(outputPath))
throw new Error(`Failed to ensure MediaPipe vision task asset for ${key}: missing or empty file at ${outputPath}`)
}
await fs.mkdir(wasmOutputDir, { recursive: true })
await fs.cp(wasmSourceDir, wasmOutputDir, { recursive: true, force: true })
const wasmEntries = await fs.readdir(wasmOutputDir)
if (!wasmEntries.length)
throw new Error(`Failed to ensure MediaPipe WASM assets: ${wasmOutputDir} is empty`)
console.log('All MediaPipe vision task assets are prepared.')
View on GitHub (pinned to 27111382b4)
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.
Example fix
# before ls node_modules/@mediapipe/tasks-vision/wasm # empty # after pnpm -F @proj-airi/model-driver-mediapipe install --force ls node_modules/@mediapipe/tasks-vision/wasm # vision_packed_assets_loader.js, *.wasm ... pnpm -F @proj-airi/model-driver-mediapipe prepare-assets
Defensive patterns
Strategy: validation
Validate before calling
import { readdir } from 'node:fs/promises'
import { existsSync } from 'node:fs'
const wasmSrc = 'node_modules/@mediapipe/tasks-vision/wasm'
if (!existsSync(wasmSrc) || (await readdir(wasmSrc)).length === 0) {
throw new Error('@mediapipe/tasks-vision wasm dir missing; run pnpm install --force')
} Try / catch
try {
await import('./prepare-tasks')
} catch (error) {
if (error instanceof Error && /WASM assets.*is empty/.test(error.message)) {
// reinstall the dependency and rerun prepare-assets
} else throw error
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to download MediaPipe vision task asset for ${key} af
- Failed to ensure MediaPipe vision task asset for ${key}: mis
- Godot stage exported binary not found. Expected at: ${join(p
- Invalid semver: ${version}
- Prerelease sequence overflow for ${stage}: ${sequence} excee
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/430c1a235429d62c.
Report an issue: GitHub.