-
-
Notifications
You must be signed in to change notification settings - Fork 257
Description
Version
System:
OS: macOS 15.3
CPU: (10) arm64 Apple M1 Pro
Memory: 81.33 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Browsers:
Chrome: 133.0.6943.54
Safari: 18.3Details
I encountered a problem with the default onError handler of the server proxy.
At the moment the handler only logs the error. The response is not getting closed (which is normally done by calling res.end("...")). If an error happens, the request will stay open forever in the browser.
Here is the corresponding line:
rsbuild/packages/core/src/server/proxy.ts
Line 33 in b5e7de0
| const handleError = (err: unknown) => logger.error(err); |
Since the default onError handler will be used, if no handler is passed, the default error handler of http-proxy-middleware will not be executed.
http-proxy-middleware is handling the error correctly by closing it, see:
https://github.com/chimurai/http-proxy-middleware/blob/1ee26edc1103e96e22b1d38b3de118bc21bfc57e/src/plugins/default/error-response-plugin.ts#L17
If no onError handler is configured, the requests keep staying in the pending state. In the console you can see, that the proxy error was already logged:

After setting the onError handler to false, the default http-proxy-middleware error handler is used and the requests correctly resolve to an error:

Setting the onError handler to false to get it to work is not intuitive and also not documented. We should either have a correct default handler, which closes the response, or we should not define a default handler, to let http-proxy-middleware handle it.
Reproduce link
https://codesandbox.io/p/github/miindlek/rsbuild-codesandbox-example/main?import=true
Reproduce Steps
- Open the dev console
- Click on the Button multiple times.
- See the network tab. Requests are still hanging.
- See the proxy already logged the error in the console.