{"record":{"id":"94d04d2627594491","repo":"denoland/deno","slug":"failed-to-load","errorCode":null,"errorMessage":"failed to load '{}': {}","messagePattern":"failed to load '(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/eszip/v2.rs","lineNumber":1377,"sourceCode":"      npm_snapshot: &ValidSerializedNpmResolutionSnapshot,\n    ) -> Result<\n      Option<Box<dyn DoubleEndedIterator<Item = ToVisit<'a>> + 'a>>,\n      anyhow::Error,\n    > {\n      let module = match graph.try_get(visited.specifier()) {\n        Ok(Some(module)) => module,\n        Ok(None) => {\n          return Err(anyhow::anyhow!(\n            \"module not found {}\",\n            visited.specifier()\n          ));\n        }\n        Err(err) => {\n          if visited.is_dynamic() {\n            // dynamic imports are allowed to fail\n            return Ok(None);\n          }\n          return Err(anyhow::anyhow!(\n            \"failed to load '{}': {}\",\n            visited.specifier(),\n            err\n          ));\n        }\n      };\n\n      let specifier_key =\n        resolve_specifier_key(module.specifier(), relative_file_base)?;\n      if modules.contains_key(specifier_key.as_ref()) {\n        return Ok(None);\n      }\n\n      match module {\n        deno_graph::Module::Js(module) => {\n          let source: Arc<[u8]>;\n          let source_map: Arc<[u8]>;\n          match module.media_type {","sourceCodeStart":1359,"sourceCodeEnd":1395,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/libs/eszip/v2.rs#L1359-L1395","documentation":"During eszip creation, graph.try_get returned an error for the named specifier: the module failed to load or resolve when the graph was built. Static (import statement) failures abort eszip creation; dynamic imports are tolerated and skipped (the function returns Ok(None)).","triggerScenarios":"A static import of a module that failed to load — 404 remote URL, unreadable local file, unsupported scheme — while building the eszip/compiled binary.","commonSituations":"Network failures during `deno compile` of remote dependencies; a file renamed after the graph was cached; importing a URL that now serves an error page.","solutions":["Fix the underlying load error for the named specifier (check URL/file availability, run `deno cache --reload`)","If the module is optional, switch to a dynamic `import()` — eszip skips failing dynamic imports","Re-run the build once the dependency is reachable again"],"exampleFix":"// before — static import of an occasionally unavailable module\nimport { x } from \"https://example.com/flaky/mod.ts\";\n\n// after — dynamic import; eszip tolerates its failure\nconst { x } = await import(\"https://example.com/flaky/mod.ts\");","handlingStrategy":"try-catch","validationCode":"# surface load errors before the eszip step\ndeno cache --reload entry.ts && deno compile entry.ts","typeGuard":null,"tryCatchPattern":"match build_eszip(graph, npm_packages) {\n  Err(e) if e.to_string().starts_with(\"failed to load '\") => {\n    // extract the failing specifier from the message, report it,\n    // or fall back to a previously built artifact\n    report_and_fallback(e)\n  }\n  result => result?,\n}","preventionTips":["Cache and verify remote dependencies (`deno cache --reload`) before compile/bundle steps","Use dynamic import() for optional dependencies — eszip tolerates their failure","Pin remote modules to immutable versioned URLs to avoid 404 drift"],"tags":["eszip","module-graph","import","compile","network"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}