[RFC] Drop websockets in favor of HTTP chunk streaming
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Refatoração
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- javascript, node.js
Direção de pesquisa
Comece revisando os entry points propostos do cliente e do servidor Pundle HMR vinculados na issue e, em seguida, compare-os com o fluxo atual de HMR e WebSocket do webpack-dev-server. Determine o impacto no design e na compatibilidade da substituição da conexão bidirecional por HTTP chunk streaming; o trabalho estará concluído quando houver um plano de implementação acordado e um caminho de migração validado.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
- 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.
- Linguagem predominante
- JavaScript
- Estrelas
- 7.9k
- Forks
- 1.5k
- Merge médio
- 2d 12h
- PRs com merge (30d)
- 8
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de webpack/webpack-dev-server
-
Add support for Chrome DevTools WorkspacesTalvez livre de novo @AnumanyaJaiswal assumiu há 35 dias e não há nenhum pull request aberto. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
webpack/webpack-dev-server#5716 · 2 comentários · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
webpack/webpack-dev-server#5679 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
CORS localhost requests are considered invalid host and get blockedTalvez livre de novo @Jeston10 assumiu há 310 dias e não há nenhum pull request aberto. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 52/100
webpack/webpack-dev-server#5603 · 5 comentários ·
Mantenedores costumam responder em até 1 dia
-
Webpack dev server URL should be displayed more prominentlyTalvez já em andamento @snitin315 assumiu há 805 dias. Aberta
webpack/webpack-dev-server#4907 · 7 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Pwa- Service worker not workAberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
webpack/webpack-dev-server#4540 · 9 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de webpack/webpack-dev-server
Issues semelhantes
-
[bug] 提瓦特记事本原石检测框宽度较窄Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
babalae/bettergi-scripts-list#3905 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Aberta
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 87/100
dedicatedcode/reitti#1445 ·
Mantenedores costumam responder em até 1 dia
-
New tool: Uncle DeskTalvez já em andamento @github-actions assumiu hoje. Abertasubmission triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
kausalflow/tools#384 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
-
Fuzz: css syntax bug foundAbertaarea: css
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia