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

Error "Failed to allocate memory for external source map" thrown in oven-sh/bun.

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)

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.