[RFC] Drop websockets in favor of HTTP chunk streaming
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, node.js
Hướng nghiên cứu
Bắt đầu bằng cách xem xét các entry point phía client và server của Pundle HMR được đề xuất và liên kết trong issue, sau đó so sánh chúng với flow HMR và WebSocket hiện tại của webpack-dev-server. Xác định tác động đến thiết kế và khả năng tương thích của việc thay thế kết nối hai chiều bằng HTTP chunk streaming; công việc được xem là hoàn tất khi có một kế hoạch triển khai đã được thống nhất và một lộ trình migration đã được xác thực.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- 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.
- Ngôn ngữ chính
- JavaScript
- Star
- 7.9k
- Fork
- 1.5k
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của webpack/webpack-dev-server
-
Add support for Chrome DevTools WorkspacesCó thể làm lại được @AnumanyaJaiswal đã nhận 35 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
webpack/webpack-dev-server#5716 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
webpack/webpack-dev-server#5679 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CORS localhost requests are considered invalid host and get blockedCó thể làm lại được @Jeston10 đã nhận 310 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
webpack/webpack-dev-server#5603 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Webpack dev server URL should be displayed more prominentlyCó thể đã có người làm @snitin315 đã nhận 805 ngày trước. Đang mở
webpack/webpack-dev-server#4907 · 7 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Pwa- Service worker not workĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
webpack/webpack-dev-server#4540 · 9 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của webpack/webpack-dev-server
Issue tương tự
-
[bug] 提瓦特记事本原石检测框宽度较窄Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
babalae/bettergi-scripts-list#3905 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
dedicatedcode/reitti#1445 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
New tool: Uncle DeskCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mởsubmission triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
kausalflow/tools#384 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add spaced repetition schedulingĐang mởgood first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
-
Fuzz: css syntax bug foundĐang mởarea: css
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày