denoland/deno · error

expected a metafile to be present

Error message

expected a metafile to be present

What it means

The Deno bundling pipeline always requests a metafile (esbuild's JSON manifest of inputs and outputs) alongside the build. When the build response comes back without one, this internal invariant fails — Deno cannot map outputs back to entrypoints or rewrite HTML/asset references without it.

Source

Thrown at cli/tools/bundle/mod.rs:946

    if !processed.is_js {
      continue;
    }
    return Ok(
      processed
        .into_contents()
        .unwrap_or_else(|| file.contents.to_vec()),
    );
  }

  deno_core::anyhow::bail!("esbuild produced no JavaScript output")
}

fn metafile_from_response(
  response: &BuildResponse,
) -> Result<esbuild_client::Metafile, AnyError> {
  Ok(serde_json::from_str::<esbuild_client::Metafile>(
    response.metafile.as_deref().ok_or_else(|| {
      deno_core::anyhow::anyhow!("expected a metafile to be present")
    })?,
  )?)
}

async fn bundle_watch(
  flags: Arc<Flags>,
  bundler: EsbuildBundler,
  minified: bool,
  platform: BundlePlatform,
  output_dir: Option<&Path>,
) -> Result<(), AnyError> {
  let (initial_roots, always_watch) = match &bundler.input {
    BundlerInput::Entrypoints(entries) => (
      entries
        .iter()
        .filter_map(|(_, root)| {
          let url = Url::parse(root).ok()?;
          deno_path_util::url_to_file_path(&url).ok()

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Re-run the bundle once to rule out a transient IPC hiccup with the esbuild service
  2. Update deno to the latest version — the bundled esbuild protocol changes in lockstep with the CLI
  3. If reproducible, minimize the entry and file a deno issue with the command and `deno --version` output
Defensive patterns

Strategy: try-catch

Try / catch

Wrap `deno bundle` in scripts with a retry-once wrapper: catch this internal error, re-run once, and fail loudly with the command + `deno --version` if it repeats — it is not fixable from user code.

Prevention

When it happens

Trigger: An esbuild build response missing the metafile field: a version/protocol mismatch with the esbuild service deno drives, or an internal bug where the build request lost its `metafile: true` setting.

Common situations: Almost always an internal deno/esbuild integration issue rather than user config — e.g. after upgrading deno mid-pipeline, or unusual modes (watch, HTML) exercising a less-tested path.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/e85d72f05f604d85. Report an issue: GitHub.