server hmr and client hmr triggered by a shared module change cause temporary inconsistent render

Aperta
#666 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
react, typescript, vite

Direzione di ricerca

Inizia eseguendo packages/plugin-rsc/examples/hmr e analizza il flusso di App, Item e lookup.ts condiviso. Riproduci il problema modificando lookup.ts o salvando insieme i moduli server e client. Il lavoro è completato quando gli aggiornamenti HMR del server e del client vengono renderizzati in modo coerente, senza che la risposta RSC e il codice client utilizzino versioni diverse del modulo.

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

Descrizione

plugin: rsc
Related plugins
Describe the bug

Raising as requested by @hi-ogawa

I've created a reproduction of the issue. The reproduction is where there's a module used on both the client and the server. A change to this shared module throws an error because the server rsc fetch uses the latest version of the module but the client code uses the old version of the module.

There is another way to reproduce the problem without a shared module. Edit a server module and client module at the same time. So make changes to them both without saving individually and then press save all to save them both together.

The problem in a nutshell is that the rsc fetch uses the latest code and the subsequent client render uses the old code.

Reproduction

https://github.com/grahammendick/vite-plugin-react/tree/navigation-vite/packages/plugin-rsc/examples/hmr

Steps to reproduce

The App just renders a client Item component passing in a key which It gets from 'lookup.ts'. The Item passes this key into 'lookup.ts' to get the value which it then displays. If you edit the key in 'lookup.ts' from 'a' to 'b', for example, then the hmr update throws.

export const key = 'b'

The reason for the error is that the server response uses the latest 'lookup.ts' but the client uses the old 'lookup.ts'. So the rsc response has the key 'b' but the client still has the key 'a'.

System Info
System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 78.34 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 10.13.1 - ~/.nvm/versions/node/v22.12.0/bin/pnpm
    bun: 1.2.5 - ~/.nvm/versions/node/v22.12.0/bin/bun
    Watchman: 2024.10.07.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 138.0.7204.184
    Safari: 17.6
  npmPackages:
    @vitejs/plugin-react: latest => 4.7.0 
    @vitejs/plugin-rsc: latest => 0.4.16 
    vite: ^7.0.4 => 7.0.4
Used Package Manager

npm

Logs

No response

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.