oven-sh/bun · error
Failed to allocate memory for external source map
Error message
Failed to allocate memory for external source map
What it means
While writing output files, allocating the buffer for an external (file-based) source map failed — an allocation error surfaced as this message. The build cannot emit the requested external sourcemap for the chunk.
Solutions
- Free memory or increase process/container memory limits
- Switch to inline source maps (smaller allocations) or disable sourcemaps
- Reduce chunk size so the sourcemap allocation fits
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/bundler/linker_context/writeOutputFilesToDisk.rs:300 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/40e1bf4442f065bd.
Report an issue: GitHub.
Appendix: source
Thrown at src/bundler/linker_context/writeOutputFilesToDisk.rs:300
chunk.intermediate_output = intermediate_output;
let mut source_map_output_file: Option<OutputFile> = None;
let input_path: Box<[u8]> = Box::from(if chunk.entry_point.is_entry_point() {
parse_graph.input_files.items_source()[chunk.entry_point.source_index() as usize]
.path
.text
} else {
&chunk.final_rel_path
});
match chunk.content.sourcemap(c.options.source_maps) {
tag @ (SourceMapOption::External | SourceMapOption::Linked) => {
let output_source_map = chunk
.output_source_map
.finalize(&code_result.shifts)
.unwrap_or_else(|_| {
panic!("Failed to allocate memory for external source map")
});
let source_map_final_rel_path = strings::concat(&[&chunk.final_rel_path, b".map"]);
if tag == SourceMapOption::Linked {
let [a, b] = if !public_path.is_empty() {
cheap_prefix_normalizer(public_path, &source_map_final_rel_path)
} else {
[b"" as &[u8], paths::basename(&source_map_final_rel_path)]
};
let source_map_start = b"//# sourceMappingURL=";
let total_len = code_result.buffer.len()
+ source_map_start.len()
+ a.len()
+ b.len()
+ b"\n".len();
let mut buf: Vec<u8> = Vec::with_capacity(total_len);
buf.extend_from_slice(&code_result.buffer);View on GitHub (pinned to 8c5296ac45)