There's no proper backpressure control for HTTP servers
It seems like backpressure mechanism in uWS is mainly built for WebSocket servers. While implementing streaming in UltimateExpress, it was revealed that when using `write` method, by the time it returns `false` (meaning backpressure was reached), the stream is already broken in browsers (ERR_INVALID_CHUNKED_ENCODING error). `getBufferedAmount` doesn't exist for HTTP servers, only for WS.
Some relevant issues from UltimateExpress:
- https://github.com/dimdenGD/ultimate-express/issues/179
- https://github.com/dimdenGD/ultimate-express/pull/199
Right now UltimateExpress deals with this by adding buffering and sending chunks every 50 milliseconds:
https://github.com/dimdenGD/ultimate-express/blob/f2e2663ed04f0c426a92947a655442c326287626/src/response.js#L158
21 条评论