moeru-ai/airi · error · Error

Failed to ensure MediaPipe WASM assets

Error message

Failed to ensure MediaPipe WASM assets: ${wasmOutputDir} is empty

What it means

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.

Solutions

  1. Reinstall dependencies cleanly: remove node_modules (and the pnpm store entry if needed) and run pnpm install, then re-run the task.
  2. 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.
  3. If you upgraded @mediapipe/tasks-vision, check whether its wasm path changed and update wasmSourceDir in tasks/prepare-tasks.ts accordingly.
  4. As a stopgap, manually copy the wasm files into the printed wasmOutputDir and re-run — the script only asserts non-emptiness.
Defensive patterns

Strategy: validation

Validate before calling

import { readdir } from 'node:fs/promises'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const wasmSource = require.resolve('@mediapipe/tasks-vision')
const entries = await readdir(join(dirname(wasmSource), 'wasm')).catch(() => [])
if (!entries.length) {
  // reinstall @mediapipe/tasks-vision before running the prepare task
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18). Data as JSON: /api/errors/430c1a235429d62c. Report an issue: GitHub.

Appendix: 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 677329427f)