{"record":{"id":"40e1bf4442f065bd","repo":"oven-sh/bun","slug":"failed-to-allocate-memory-for-external-source-map","errorCode":null,"errorMessage":"Failed to allocate memory for external source map","messagePattern":"Failed to allocate memory for external source map","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bundler/linker_context/writeOutputFilesToDisk.rs","lineNumber":300,"sourceCode":"        chunk.intermediate_output = intermediate_output;\n\n        let mut source_map_output_file: Option<OutputFile> = None;\n\n        let input_path: Box<[u8]> = Box::from(if chunk.entry_point.is_entry_point() {\n            parse_graph.input_files.items_source()[chunk.entry_point.source_index() as usize]\n                .path\n                .text\n        } else {\n            &chunk.final_rel_path\n        });\n\n        match chunk.content.sourcemap(c.options.source_maps) {\n            tag @ (SourceMapOption::External | SourceMapOption::Linked) => {\n                let output_source_map = chunk\n                    .output_source_map\n                    .finalize(&code_result.shifts)\n                    .unwrap_or_else(|_| {\n                        panic!(\"Failed to allocate memory for external source map\")\n                    });\n                let source_map_final_rel_path = strings::concat(&[&chunk.final_rel_path, b\".map\"]);\n\n                if tag == SourceMapOption::Linked {\n                    let [a, b] = if !public_path.is_empty() {\n                        cheap_prefix_normalizer(public_path, &source_map_final_rel_path)\n                    } else {\n                        [b\"\" as &[u8], paths::basename(&source_map_final_rel_path)]\n                    };\n\n                    let source_map_start = b\"//# sourceMappingURL=\";\n                    let total_len = code_result.buffer.len()\n                        + source_map_start.len()\n                        + a.len()\n                        + b.len()\n                        + b\"\\n\".len();\n                    let mut buf: Vec<u8> = Vec::with_capacity(total_len);\n                    buf.extend_from_slice(&code_result.buffer);","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/bundler/linker_context/writeOutputFilesToDisk.rs#L282-L318","documentation":"Error \"Failed to allocate memory for external source map\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/bundler/linker_context/writeOutputFilesToDisk.rs:300 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}