Skip to content

@sentry/vite-plugin: uploaded source maps have backslash sources on Windows since 11.16.0 (sentry CLI 0.50.0) #26788

In review

Description

@cr101

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/vite-plugin

SDK Version

11.17.0 (also 11.16.0; sentry CLI 0.50.0)

Framework Version

Vite 8.3.8, Node.js 26.13.1, Windows 11 x64

Link to Sentry event

None. Reproduced against a local mock of the upload API; the issue is in the uploaded artifact bundle, before any event is processed.

Reproduction Example/SDK Setup

Minimal project (index.html loads src/main.js):

// src/main.js
import { nanoid } from 'nanoid'
document.body.textContent = nanoid()
// vite.config.js
import { defineConfig } from 'vite'
import { sentryVitePlugin } from '@sentry/vite-plugin'

export default defineConfig({
  build: { sourcemap: 'hidden' },
  plugins: [
    sentryVitePlugin({
      authToken: process.env.SENTRY_AUTH_TOKEN,
      org: process.env.SENTRY_ORG,
      project: process.env.SENTRY_PROJECT,
      release: { name: 'repro-1', setCommits: false, finalize: false },
    }),
  ],
})

Dependencies: vite@8.3.8, nanoid@5, @sentry/vite-plugin@11.17.0.

Steps to Reproduce

  1. On Windows, run npx vite build with upload credentials (I used a local mock of the Sentry API via url, and captured the chunk-upload body).
  2. Compare sources in the map Vite wrote (dist/assets/*.js.map) with sources in the uploaded artifact bundle's .js.map.

Expected Result

The uploaded map keeps URL-style sources with forward slashes, as Vite wrote them and as 11.14.0 uploaded them:

["../../node_modules/nanoid/url-alphabet/index.js", "../../node_modules/nanoid/index.browser.js", "../../src/main.js"]

Actual Result

With 11.16.0 / 11.17.0, the uploaded map's sources use Windows backslashes:

["..\\..\\node_modules\\nanoid\\url-alphabet\\index.js", "..\\..\\node_modules\\nanoid\\index.browser.js", "..\\..\\src\\main.js"]

The same project with @sentry/vite-plugin@11.14.0 (sentry CLI 0.49.0) uploads forward slashes. The map on disk (dist/assets) has forward slashes in both cases; only the uploaded copy differs.

The source map spec treats sources as URLs, so frames resolved from these maps carry Windows-style paths. Builds of the same commit on Windows and Linux produce different frame paths, and path-based features such as stack trace links (code mappings) expect /.

Additional Context

I believe the cause is two changes interacting:

  1. defaultRewriteSourcesHook in @sentry/bundler-plugins (build/esm/core/debug-id-upload.js, unchanged from 11.14.0 to 11.17.0) returns path.relative(process.cwd(), path.normalize(source)). On Windows, path.normalize and path.relative return backslash paths, so every sources entry in the staged upload copy gets backslashes.
  2. Until 11.16.0 this was hidden. The sentry CLI's injection step converts sources back with replaceAll("\\", "/"), and with CLI 0.49.0 that step always ran on Vite 8 output, because the CLI did not recognise the Oxc-minified debug-ID snippet and injected a second one (Vite 8 source maps are uploaded one line off until the sentry CLI range allows 0.50.0 #26658; the uploaded chunk above has 6 _sentryDebugIds occurrences at 11.14.0, against 3 at 11.17.0). CLI 0.50.0 (fix(deps): Bump the sentry CLI to ^0.50.0 #26662) recognises the existing snippet and returns early (wasInjected: false) before that conversion, so the backslashes from step 1 now reach the upload.

Possible fix: make defaultRewriteSourcesHook return POSIX separators, for example path.posix operations or .replace(/\\/g, '/') on the result, rather than relying on the CLI's injection step. That would also give user-supplied rewriteSources hooks consistent input.

Workaround: pass an identity hook, sourcemaps: { rewriteSources: (source) => source }. The uploaded map then keeps the forward-slash sources Vite wrote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions