plugin-rsc: inject-async-local-storage transform drops source maps

Aperta
#1,418 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript

Direzione di ricerca

Inizia da globalAsyncLocalStoragePlugin nel pacchetto plugin-rsc ed esegui la riproduzione collegata con npm ci e npm run repro. Traccia la trasformazione rsc:inject-async-local-storage e individua la posizione appropriata per il test. Il lavoro è completato quando il modulo trasformato conserva le mappe sorgente, il marker viene risolto in src/entry.js:6 e l’avviso SOURCEMAP_BROKEN è scomparso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

pending triage plugin: rsc
Related plugins
Describe the bug

The rsc:inject-async-local-storage transform changes modules containing both typeof AsyncLocalStorage and new AsyncLocalStorage(), but it does not return a source map for that transformation.

With Vite 8.2.1, the RSC and SSR builds emit SOURCEMAP_BROKEN naming this transform. The final emitted map cannot resolve a marker in the transformed source to any original position: the expected location is src/entry.js:6, while originalPositionFor returns source=null, line=null, column=null.

Expected: the transform preserves and composes source mappings, the marker resolves to src/entry.js:6, and Vite emits no source-map warning for this transform.

Actual: the transformed module loses its original mapping. This can cause incorrect or missing stack-frame symbolication in production error monitoring.

The likely location is globalAsyncLocalStoragePlugin, which prepends initialization text and returns only transformed code. I can submit a patch and test if maintainers confirm the preferred test location.

Reproduction

https://github.com/FieldArchiveTX/vite-plugin-rsc-sourcemap-repro

Steps to reproduce
  1. Clone the reproduction repository.
  2. Run npm ci.
  3. Run npm run repro.
  4. Observe two SOURCEMAP_BROKEN warnings for rsc:inject-async-local-storage and the verifier output showing a null original position.

The reproduction command exits successfully when the defect is reproduced.

System Info
System:
  OS: Windows 11 10.0.26200
  CPU: x64 Intel Core i7-14700KF
Binaries:
  Node: 24.14.0
  npm: 10.9.2
Browsers:
  Chrome: 150.0.7871.187
npmPackages:
  @vitejs/plugin-rsc: 0.5.34
  vite: 8.2.1
  react: 19.2.8
  react-dom: 19.2.8
  react-server-dom-webpack: 19.2.8
Used Package Manager

npm

Logs
[plugin rsc:inject-async-local-storage] [SOURCEMAP_BROKEN]
Sourcemap is likely to be incorrect: a plugin (rsc:inject-async-local-storage) was used to transform files, but didn't generate a sourcemap for the transformation.

expected: src/entry.js:6
traced: source=null, line=null, column=null

REPRODUCED: the emitted source map does not resolve the marker to its source line.
Validations
Lingua principale
TypeScript
Stelle
1.2k
Fork
287
Merge medio
1g 17h
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vitejs/vite-plugin-react

Tutte le issue di vitejs/vite-plugin-react

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.