Skip to content

fix(server): skip fallback sourcemap for large responses to avoid OOM#22776

Open
raminjafary wants to merge 1 commit into
vitejs:mainfrom
raminjafary:fix/raw-large-file-sourcemap-oom
Open

fix(server): skip fallback sourcemap for large responses to avoid OOM#22776
raminjafary wants to merge 1 commit into
vitejs:mainfrom
raminjafary:fix/raw-large-file-sourcemap-oom

Conversation

@raminjafary

Copy link
Copy Markdown

The dev server generates a fallback sourcemap with hires: 'boundary' and includeContent for JS modules that lack one. For very large modules (e.g. a big file imported via ?raw) this map amplifies memory usage enough to crash the server with an out-of-memory error. Skip the fallback sourcemap, which is only a debugging aid, once the code exceeds 4MB.

Fixes #22132

@raminjafary raminjafary force-pushed the fix/raw-large-file-sourcemap-oom branch 3 times, most recently from 7dcea1b to 6fd406c Compare June 25, 2026 21:13
The dev server generates a fallback sourcemap with hires: 'boundary' and
includeContent for JS modules that lack one. For very large modules (e.g. a
big file imported via ?raw) this map amplifies memory usage enough to crash
the server with an out-of-memory error. Skip the fallback sourcemap, which is
only a debugging aid, once the code exceeds 4MB.

Fixes vitejs#22132
@raminjafary raminjafary force-pushed the fix/raw-large-file-sourcemap-oom branch from 6fd406c to d671aa3 Compare June 25, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

?raw import of large file with many newlines causes OOM (153x memory amplification from sourcemap generation)

1 participant