Run React Refresh at vite:afterUpdate instead of after a fixed 16 ms
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
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript, vite
- Ambito
- build-system, frontend
Direzione di ricerca
Start in packages/common/refresh-runtime.js, where enqueueUpdate is a debounce with a 16 ms delay that runs the hooks and then performReactRefresh. Look at how the client emits vite:afterUpdate and where validateRefreshBoundaryAndEnqueueUpdate is called. Done means flushing the pending refresh on vite:afterUpdate while the timer still covers enqueues outside an update. Check the timing in the existing refresh tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Drafted with an AI assistant (Claude), reviewed by me.
Related plugins
- plugin-react
Description
React Refresh runs 16 ms after the last accepted module (packages/common/refresh-runtime.js, 6.3.0):
const enqueueUpdate = debounce(async () => {
if (hooks.length) await Promise.all(hooks.map((cb) => cb()))
performReactRefresh()
}, 16)
So every Fast Refresh edit waits at least 16 ms after its modules have run.
We see it in TanStack Router, which waits for the pass through __registerBeforePerformReactRefresh before applying a route edit: an edit of only a route's loader went from 16.9 to 36.8 ms save-to-DOM when we started waiting (1,485-route app).
Suggested solution
By the time the client emits vite:afterUpdate, every module of the payload has run its accept callback, so every validateRefreshBoundaryAndEnqueueUpdate call of that update has been made. Flush there, and keep the timer for enqueues outside an update:
import.meta.hot.on('vite:afterUpdate', () => flushPendingRefresh())
Alternative
Keep the debounce but expose a way to flush it.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines
- Read the docs
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate
- Lingua principale
- TypeScript
- Stelle
- 1.2k
- Fork
- 287
- Merge medio
- 1g 17h
- PR unite (30g)
- 19
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vitejs/vite-plugin-react
-
plugin-rsc: a client reference's CSS is linked before the CSS of the chunks it imports (build)Forse già presa @wozhenbang2004 l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
vitejs/vite-plugin-react#1570 ·
I maintainer di solito rispondono entro 1 giorno
-
pending triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
vitejs/vite-plugin-react#1581 ·
I maintainer di solito rispondono entro 1 giorno
-
[plugin-rsc] Build exits 0, but the app fails at runtime: a server action imported only by browser code is missing from the RSC buildForse già presa @NeilPant l’ha presa 3 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
vitejs/vite-plugin-react#1578 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
vitejs/vite-plugin-react#1577 ·
I maintainer di solito rispondono entro 1 giorno
-
[plugin-rsc] inline "use server" function declarations lose hoisting and throw TDZ ReferenceErrorForse già presa @draarivpatel-ui l’ha presa 2 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
vitejs/vite-plugin-react#1566 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vitejs/vite-plugin-react
Issue simili
-
ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
mermaid-js/mermaid-v13#1370 ·
I maintainer di solito rispondono entro 1 giorno
-
compiler: the island_chunks_not_emitted report gives a count but not which islands were skippedApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Broken Website
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
darkreader/darkreader#16259 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ARTPARK-SAHAI-ORG/calibrate-frontend#919 ·
I maintainer di solito rispondono entro 1 giorno