[RFC] Drop websockets in favor of HTTP chunk streaming
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, node.js
Línea de trabajo
Empieza revisando los puntos de entrada propuestos del cliente y del servidor de Pundle HMR enlazados en el issue y, después, compáralos con el flujo actual de HMR y WebSocket de webpack-dev-server. Determina el impacto en el diseño y la compatibilidad de reemplazar la conexión bidireccional por HTTP chunk streaming; se considerará terminado cuando exista un plan de implementación acordado y una ruta de migración validada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
- 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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 7.9k
- Forks
- 1.5k
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 8
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de webpack/webpack-dev-server
-
Add support for Chrome DevTools WorkspacesQuizá libre de nuevo @AnumanyaJaiswal la tomó hace 35 días y no hay ningún pull request abierto. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
webpack/webpack-dev-server#5716 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
webpack/webpack-dev-server#5679 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
CORS localhost requests are considered invalid host and get blockedQuizá libre de nuevo @Jeston10 la tomó hace 310 días y no hay ningún pull request abierto. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
webpack/webpack-dev-server#5603 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Webpack dev server URL should be displayed more prominentlyPosiblemente ocupada @snitin315 la tomó hace 805 días. Abierto
webpack/webpack-dev-server#4907 · 7 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Pwa- Service worker not workAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
webpack/webpack-dev-server#4540 · 9 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de webpack/webpack-dev-server
Issues similares
-
[bug] 提瓦特记事本原石检测框宽度较窄Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
babalae/bettergi-scripts-list#3905 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 87/100
dedicatedcode/reitti#1445 ·
Los mantenedores suelen responder en 1 día
-
New tool: Uncle DeskPosiblemente ocupada @github-actions la tomó hoy. Abiertosubmission triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
kausalflow/tools#384 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add spaced repetition schedulingAbiertogood first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
-
Fuzz: css syntax bug foundAbiertoarea: css
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día