{"record":{"id":"9ecd2f9acbcb7495","repo":"denoland/deno","slug":"could-not-get-emit-filename","errorCode":null,"errorMessage":"Could not get emit filename.","messagePattern":"Could not get emit filename\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/resolver/cache/emit.rs","lineNumber":108,"sourceCode":"      // assume the cache can't be written to and disable caching to it\n      self.emit_failed_flag.raise();\n    }\n  }\n\n  fn set_emit_code_result(\n    &self,\n    specifier: &Url,\n    source_hash: u64,\n    code: &[u8],\n  ) -> Result<(), AnyError> {\n    if matches!(self.mode, Mode::Disable) || self.emit_failed_flag.is_raised() {\n      log::debug!(\"Skipped emit cache save of {}\", specifier);\n      return Ok(());\n    }\n\n    let emit_filename = self\n      .get_emit_filename(specifier)\n      .ok_or_else(|| anyhow!(\"Could not get emit filename.\"))?;\n    let cache_data = self.file_serializer.serialize(code, source_hash);\n    self.disk_cache.set(&emit_filename, &cache_data)?;\n\n    Ok(())\n  }\n\n  fn get_emit_filename(&self, specifier: &Url) -> Option<PathBuf> {\n    self\n      .disk_cache\n      .get_cache_filename_with_extension(specifier, \"js\")\n  }\n}\n\nconst LAST_LINE_PREFIX: &str = \"\\n// denoCacheMetadata=\";\n\n#[derive(Debug)]\nstruct EmitFileSerializer {\n  cache_version: Cow<'static, str>,","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/libs/resolver/cache/emit.rs#L90-L126","documentation":"EmitCache::set_cache derives a cache filename through the disk cache's URL-to-filename logic. For URL schemes it cannot name (anything outside wasm/http/https/data/blob/file, or a file/data URL that fails conversion) get_emit_filename returns None and the save aborts with this error — unless emit is disabled or the emit-failed flag is already raised, in which case the save is skipped.","triggerScenarios":"Saving transpile emit for a specifier whose scheme the disk cache cannot map to a filename: npm:, jsr: or node: specifiers routed through EmitCache, or a data: URL whose contents url_to_filename rejects.","commonSituations":"Custom loaders/resolvers surfacing exotic schemes into the emit pipeline; very long data: URL imports; embedders reusing EmitCache outside the CLI's normal file/http flow.","solutions":["Restrict emit caching to module URLs with cacheable schemes (file/http/https/blob/wasm/data)","Avoid importing via data: URLs in code whose emit will be cached","If embedding EmitCache, pre-check scheme support and skip saving instead of erroring"],"exampleFix":"// before — save unconditionally, errors on non-cacheable schemes\nemit_cache.set_cache(&specifier, source_hash, &code).await?;\n\n// after — only save when the disk cache can name the specifier\nlet cacheable = matches!(\n  specifier.scheme(),\n  \"file\" | \"http\" | \"https\" | \"data\" | \"blob\" | \"wasm\"\n);\nif cacheable {\n  emit_cache.set_cache(&specifier, source_hash, &code).await?;\n}","handlingStrategy":"fallback","validationCode":"// only attempt emit-cache saves for schemes the disk cache can name\nfn is_emit_cacheable(specifier: &url::Url) -> bool {\n  matches!(\n    specifier.scheme(),\n    \"file\" | \"http\" | \"https\" | \"data\" | \"blob\" | \"wasm\"\n  )\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid data: URL imports in code that goes through the emit cache","Keep custom-scheme loaders (npm:, jsr:, node:) out of the emit path or skip caching for them","Treat emit-cache save failures as cache misses where the caller allows skipping"],"tags":["cache","emit","transpile","specifier","resolver"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}