Community JavaScript Snippet

Resolving a Production Stack Trace Against a Source Map

When a minified Sentry stack only points at `bundle.js:1:140183`, this is the zero-dep VLQ decoder I drop in to map every frame back to a real source line.

Resolving a Production Stack Trace Against a Source Map

When a minified Sentry stack only points at `bundle.js:1:140183`, this is the zero-dep VLQ decoder I drop in to map every frame back to a real source line.

JavaScript
Frontend
3 snippets
debugging
error-handling
source-maps
utility
kwamehenderson

By @kwamehenderson

January 20, 2026

·

Updated May 20, 2026

1,146 views

17

4.3 (11)

Source maps are a JSON file with a mappings field: a string of base64 VLQ groups separated by commas (one segment) and semicolons (one generated line). Each segment is up to five signed integers (genCol delta, sourceIdx delta, sourceLine delta, sourceCol delta, nameIdx delta). The decoder unpacks the bits five at a time, peels the sign bit, and accumulates deltas across segments. I keep this around because every "add a sourcemap library" PR I have reviewed pulled in source-map (300 KB) for what is genuinely a 30-line job. The output is one array of segments per generated line, ready for binary search.