Skip to Content
KubeSense

Source Maps for Browser Errors

Upload each release's JavaScript source maps from CI so browser error stacks show your original files, lines and function names instead of minified code.

Production JavaScript is bundled and minified, so the stack of a browser error points at a column of a one-line file:

RangeError: invalid quantity 0 for sku-2
  at t @ https://shop.example.com/assets/checkout.min.js:1:92
  at e @ https://shop.example.com/assets/checkout.min.js:1:36

Upload the source maps your bundler writes for each release, and KubeSense shows the same error in your source:

RangeError: invalid quantity 0 for sku-2
  at lineTotal @ ../src/pricing.ts:9:15
  at orderTotal @ ../src/pricing.ts:4:16

Your source maps never have to be public. You upload them from CI and can delete them before you deploy; KubeSense never fetches anything from your site.

Before you start

You need:

  • service and version set in the RUM SDK. A map is chosen by the error's service and version, so an error without a version can never be resolved. Set both in init() (see Browser Integration), and change version with every release.
  • An ingestion token. Create one in Settings → Ingestion Tokens. Do not use your RUM application's client token: it ships inside your public JavaScript, so KubeSense refuses it for uploads.
  • Your RUM intake URL: https:// followed by the host you set as kubesenseRumEndpoint, for example https://app.kubesense.ai.
  • Node.js 18.3 or later on the CI runner, for npx @kubesense/kubesense-ci.

1. Build hidden source maps

Have your bundler write .map files without the //# sourceMappingURL= comment, so browsers never ask for them:

BundlerSetting
Vitebuild: { sourcemap: 'hidden' }
webpackdevtool: 'hidden-source-map'
Rollupoutput: { sourcemap: 'hidden' }
esbuild--sourcemap=external
Next.jsproductionBrowserSourceMaps: true (delete the maps after uploading, below)

Each map must sit next to the file it maps: checkout.min.js.map beside checkout.min.js.

2. Upload them in CI

Run the KubeSense CLI after the build and before the deploy:

export KUBESENSE_API_KEY=<ingestion token>
export KUBESENSE_SOURCEMAP_INTAKE_URL=https://app.kubesense.ai

npx @kubesense/kubesense-ci sourcemaps upload ./dist \
  --service=web-shop \
  --release-version="$APP_VERSION" \
  --minified-path-prefix=/ \
  --delete-maps

Each file's URL is the prefix followed by its path below the uploaded directory. Vite writes dist/assets/index-abc.js, served at /assets/index-abc.js, so ./dist takes the prefix /. Run once with --dry-run to print the URLs, and check them against the .js URLs in your error stacks.

OptionWhat it is
--serviceThe service your RUM SDK reports
--release-versionThe version your RUM SDK reports for this build
--minified-path-prefixWhere the uploaded directory is served from: a path (/, /static/) or a URL (https://cdn.example.com/). Only the path is compared, so the same bundle served from a CDN and from your own domain both match.
--delete-mapsDelete each .map once it is uploaded, so it is never deployed. A map that is not uploaded (its upload failed, or no .js file sits beside it) is kept and fails the run, so the deploy after it does not ship it. Stylesheet maps (.css.map) are neither uploaded nor deleted.
--dry-runList the maps that would be uploaded, upload nothing. With --delete-maps it fails, as the real run would, when a map could not be uploaded.
--repository-url, --commit-shaRead from git by default. --disable-git stops reading git; values you pass are still sent.
--intake-urlThe RUM intake URL, instead of KUBESENSE_SOURCEMAP_INTAKE_URL
--max-concurrencyUploads at once (default 4)
--quietPrint only failures and the summary

--service and --release-version must equal what the SDK reports, or no error will ever match a map. The command exits non-zero if any map failed to upload, or if it found none.

If the collector's certificate comes from a private CA, set NODE_EXTRA_CA_CERTS to the CA file.

A GitHub Actions step:

- name: Upload source maps
  env:
    KUBESENSE_API_KEY: ${{ secrets.KUBESENSE_INGESTION_TOKEN }}
    KUBESENSE_SOURCEMAP_INTAKE_URL: https://app.kubesense.ai
  run: >
    npx @kubesense/kubesense-ci sourcemaps upload ./dist
    --service=web-shop
    --release-version=${{ github.sha }}
    --minified-path-prefix=/
    --delete-maps

Upload before you deploy. An error is resolved as it arrives, with the maps uploaded by then. One that arrived before its map is stored minified, and is resolved when you open it in the error drawer or an issue's samples, if the map has been uploaded since. Lists, search and alerts show the stack as it was stored.

Already using datadog-ci?

KubeSense also accepts uploads from datadog-ci sourcemaps upload. Point it at your intake and set DATADOG_SITE to a host that cannot resolve:

export DATADOG_API_KEY=<ingestion token>
export DATADOG_SOURCEMAP_INTAKE_URL=https://app.kubesense.ai   # base URL only
export DATADOG_SITE=kubesense.invalid

datadog-ci sends its own usage metrics, with the API key, to api.<DATADOG_SITE> on every run. With DATADOG_SITE=kubesense.invalid that request cannot leave your CI, and it only prints a warning; without it, your KubeSense token is sent to Datadog.

3. See the resolved stack

Open an error in RUM → Sessions Explorer, or an issue's stack trace. The stack is shown source-mapped; Minified switches to the stack exactly as the browser sent it.

When a stack stays minified, a note under it says why:

NoteWhat to do
No source map was uploaded for this service and versionCheck --service and --release-version match the SDK, and that the upload ran for this build
The source maps uploaded for this version do not match this bundleThe maps came from a different build than the one deployed. Upload from the same build output you deploy
The error has no versionSet version in the RUM SDK
The source maps could not be read when this error arrivedTemporary; open the error again
Some frames have no source mapThose frames come from a file you did not upload, often a third-party script

Good to know

  • Each map is kept for 365 days after its last upload. Uploading the same file again for the same version replaces it.
  • A map can be up to 100 MB. If a proxy or ingress sits in front of the RUM intake, it must pass /rum/api/v1/sourcemaps (and /api/v2/srcmap for datadog-ci) and allow request bodies that large; nginx allows 1 MB by default.
  • Maps are stored as uploaded, including sourcesContent (your original source). Your KubeSense administrator can have sourcesContent removed on upload; stacks still resolve.
  • Stacks from Android and iOS apps are not resolved yet.

On this page