You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Excessive memory consumption when handling large bundles without source maps #344
When an error is thrown in a large bundle, the source-map-support library unnecessarily retains the full file contents in memory. The file is loaded solely to check for a source map, but its contents are cached even after this one‑time operation. This results in excessive memory usage, especially problematic with multiple large bundles.
Steps to reproduce:
An error is thrown in a bundle (e.g., index.js)
Error.prepareStackTrace() is called
The call chain proceeds as follows: wrapCallSite() → mapSourcePosition() → retrieveSourceMap("index.js") → retrieveSourceMapURL("index.js") → retrieveFile("index.js")
The default retrieveFile handler loads the entire index.js file from disk and stores it in the fileContentsCache (source)
retrieveSourceMapURL() fails to find a source map for the file
mapSourcePosition() stores an empty source map in its internal cache (source)
The full contents of index.js remain in the fileContentsCache indefinitely, consuming memory
Expected behavior:
File contents should be used only once to check for the presence of a source map, and then either not cached at all or discarded immediately after the check. There is no need to retain large bundle files in memory after this operation.
Actual behavior:
Large bundle files (5–7 MB) are retained in the fileContentsCache after the first error, leading to unnecessary increase in memory footprint.
Proposed solution:
Avoid caching when no source map is found: skip storing file contents in fileContentsCache if the source map lookup fails.
Activity