[RFC] Drop websockets in favor of HTTP chunk streaming
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Inizia esaminando gli entry point proposti del client e del server Pundle HMR collegati nell’issue, quindi confrontali con il flusso HMR e WebSocket attuale di webpack-dev-server. Determina l’impatto sul design e sulla compatibilità della sostituzione della connessione bidirezionale con HTTP chunk streaming; il lavoro sarà considerato completato quando saranno disponibili un piano di implementazione concordato e un percorso di migrazione validato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
- This is a bug
- This is a modification request
Context
A few years ago I started working on a Module bundler from scratch (Pundle / https://github.com/steelbrain/pundle), It worked well for most simple cases and had plugin support and everything, I couldn't focus on it because of my fulltime job. I am hoping to upstream some of the clever fixes to the limitations I found working with Browserify and Webpack.
Why drop websockets?
There are many reasons for why we would want to remove Websockets from the dev server. The simplest explanation through code is that, webpack dev server consumers do this:
const app = express()
app.use('/mycoolwebsite', webpackDevServer({...})
const server = app.listen(9123, ...)
To setup a websocket server on an http server, we require access to the http server instance in NodeJS, which is only available AFTER calling .listen(), we cannot have it when registering the webpackDevServer route. Currently this is handled by setting up the websocket server on a different port inside the middleware and connecting to it instead.
It is complicated to setup webpack dev server with HMR when working with proxies. All of this can be avoided if we do simple HTTP chunking as described below.
The proposed fix
For HMR, the client just needs to listen to the server for updates, so it's a one-way communication, not bi-directional. Using fetch() API with a TextDecoder, we can keep an HTTP connection open for as long as we want and continue to write onto it from the server.
Here's the Client / Server implementation of it in Pundle: https://github.com/steelbrain/pundle/blob/fee7d9dc055591bf002b5a66190d651a02dbdfa4/packages/pundle-dev-middleware/src/client/hmr-client.js#L137-L157 / https://github.com/steelbrain/pundle/blob/4152d29de8b28be69c3e21bd3589a6109726310a/packages/pundle-dev-middleware/src/index.js#L220-L229
As you can see, we no longer need to worry about HMR port or hostname, the client JS can do a request to the server with selfUrl.webpack.hmr, it'll be routed to webpack through the same proxy that loaded the JS in the first place, webpack can then continue to write chunks on it until the client disconnects.
Benefits of proposed approach
- Massively reduce complexity for embedded dev server setups
- Reduced codebase complexity and ease of maintenance
Please let me know if there's anything I can explain to make it more understandable. Happy to do a PR implementing this change.
- Lingua principale
- JavaScript
- Stelle
- 7.9k
- Fork
- 1.5k
- Merge medio
- 2g 12h
- PR unite (30g)
- 8
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun 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 webpack/webpack-dev-server
-
Add support for Chrome DevTools WorkspacesForse di nuovo libera @AnumanyaJaiswal l’ha presa 35 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
webpack/webpack-dev-server#5716 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
webpack/webpack-dev-server#5679 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
CORS localhost requests are considered invalid host and get blockedForse di nuovo libera @Jeston10 l’ha presa 310 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
webpack/webpack-dev-server#5603 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Webpack dev server URL should be displayed more prominentlyForse già presa @snitin315 l’ha presa 805 giorni fa. Aperta
webpack/webpack-dev-server#4907 · 7 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Pwa- Service worker not workAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
webpack/webpack-dev-server#4540 · 9 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di webpack/webpack-dev-server
Issue simili
-
[bug] 提瓦特记事本原石检测框宽度较窄Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
babalae/bettergi-scripts-list#3905 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 87/100
dedicatedcode/reitti#1445 ·
I maintainer di solito rispondono entro 1 giorno
-
New tool: Uncle DeskForse già presa @github-actions l’ha presa oggi. Apertasubmission triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
kausalflow/tools#384 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
-
Fuzz: css syntax bug foundApertaarea: css
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno