Frequently hitting 'unreachable' errors with many source maps in memory
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, rust, wasm
- Domain
- tooling
Research direction
Start in lib/source-map-consumer.js around BasicSourceMapConsumer._parseMappings, _getMappingsPtr, and originalPositionFor, then inspect lib/wasm.js and the reported WebAssembly failure path. Reproduce the workload with many SourceMapConsumers and confirm whether allocation failure causes the unreachable error. Done means callers can distinguish this memory condition and recover by dropping cached data.
Written by the indexing model from the issue text.
Description
I'm operating a service which sourcemaps JavaScript Self-Profiling data from production. We have several versions of our app running concurrently, with different source maps. The service keeps an LRU cache of SourceMapConsumers with a size limit roughly calculated from smc._mappings.length. This lets us keep around 100 SourceMapConsumers active at a time before running into the WebAssembly memory limit.
However, we often see unreachable errors like the following:
RuntimeError: unreachable
at wasm://wasm/0002f63a:wasm-function[54]:0xb65c
at wasm://wasm/0002f63a:wasm-function[22]:0x9647
at BasicSourceMapConsumer._parseMappings (/work/node_modules/source-map/lib/source-map-consumer.js:306:47)
at BasicSourceMapConsumer._getMappingsPtr (/work/node_modules/source-map/lib/source-map-consumer.js:289:12)
at /work/node_modules/source-map/lib/source-map-consumer.js:500:16
at Object.withMappingCallback (/work/node_modules/source-map/lib/wasm.js:125:13)
at BasicSourceMapConsumer.originalPositionFor (/work/node_modules/source-map/lib/source-map-consumer.js:496:16)
at file:///work/dist/mapTrace.js:44:34
at file:///work/dist/mapTrace.js:53:11
at Array.map (<anonymous>)
I believe this indicates an out-of-memory error, where source-map's rust code tries to allocate something but can't.
Could it be possible to gracefully recover from this? I believe Rust doesn't really support graceful recovery from OOM, but perhaps source-map could check whether there's enough memory available to allocate for a SourceMapConsumer before allocating, and throw some other kind of error? That would allow using that signal to drop some old data from our cache.
- Dominant language
- JavaScript
- Stars
- 3.7k
- Forks
- 370
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mozilla/source-map
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
mozilla/source-map#530 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
mozilla/source-map#527 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
mozilla/source-map#524 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
mozilla/source-map#516 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
mozilla/source-map#510 · 1 reaction ·
All issues in mozilla/source-map
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Mend: dependency security vulnerability untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 70/100