From df4e42bf1c61895604c80a4b4841a5ace5300f15 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Wed, 12 Nov 2025 12:28:17 -0800 Subject: [PATCH] fix(DevServer) remove panic in case of source type none (#24634) ### What does this PR do? Remove panic in case of source type none, so we can handle it more gracefully, we can discuss if this is the best solution but looks sensible for me. This is really hard to repro but can happen when deleting files referred by dynamic imports. Fixes https://linear.app/oven/issue/ENG-21513/panic-missing-internal-precomputed-line-count-in-renderjson-on Fixes https://github.com/oven-sh/bun/issues/21714 ### How did you verify your code works? CI --------- Co-authored-by: taylor.fish --- src/bake/DevServer/SourceMapStore.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bake/DevServer/SourceMapStore.zig b/src/bake/DevServer/SourceMapStore.zig index ea65007624..26a41954e1 100644 --- a/src/bake/DevServer/SourceMapStore.zig +++ b/src/bake/DevServer/SourceMapStore.zig @@ -273,7 +273,11 @@ pub const Entry = struct { .none => { // NOTE: It is too late to compute the line count since the bundled text may // have been freed already. For example, a HMR chunk is never persisted. - @panic("Missing internal precomputed line count."); + // We could return an error here but what would be a better behavior for renderJSON and renderMappings? + // This is a dev server, crashing is not a good DX, we could fail the request but that's not a good DX either. + if (bun.Environment.enable_logs) { + mapLog("Skipping source map entry with missing line count at index {d}", .{i}); + } }, }; }