webpack-dev-server icon indicating copy to clipboard operation
webpack-dev-server copied to clipboard

Client-canceled XMLHttpRequests to proxy API cause webpack dev server to reload

Open anthonybarsotti opened this issue 10 years ago • 10 comments

I've run into an issue where if an XMLHttpRequest to a proxy API is either aborted or times out on the client it causes a proxy error and the dev server reloads the page. Does anyone know of a way around this?

anthonybarsotti avatar Mar 15 '16 18:03 anthonybarsotti

I've gotten around this temporarily by imposing the timeout on the server but I'm still curious to see if there is a solution to this.

anthonybarsotti avatar Mar 15 '16 18:03 anthonybarsotti

It looks like aborting a proxied request triggers a "proxy error" message through the socket, which causes the client to reload.

vanwagonet avatar Apr 12 '16 00:04 vanwagonet

Same issue here. Any solution?

jiarongxu avatar Jun 14 '16 20:06 jiarongxu

same issue like this?:

https://github.com/webpack/webpack-dev-server/issues/369

I think we need a way to configure/disable the timeout for long running requests.

oers avatar Jul 20 '16 07:07 oers

This can be fixed by adding the following line between lines 147 and 148 of lib/Server.js in 1.14.1:

if (err.code === 'ECONNRESET') return;

ECONNRESET means it was not actually an error but intentional by the client.

makuko avatar Aug 03 '16 11:08 makuko

I can confirm @makuko's fix works in 1.14.1. This can sometimes be very common issue for those of us using Angular 2 + RxJS.

doxavore avatar Aug 31 '16 20:08 doxavore

This was fixed with PR #478, and released with 1.15.0.

SpaceK33z avatar Sep 03 '16 14:09 SpaceK33z

I always encountered the ECONNRESET when used a proxy config in my Angular2 project(generated by Angular CLI 1.0.0 which shipped webpack-dev-server 2.3.0).

[HPM] GET /api/upload/uploads-1490782788752.png -> http://localhost:3000
[HPM] Error occurred while trying to proxy request /api/upload/uploads-1490782788752.png from localhost:4300 to http://localhost:3000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)

hantsy avatar Mar 31 '17 10:03 hantsy

@hantsy how did you get around this for Angular 2 projects?

dhatawesomedude avatar Aug 23 '17 05:08 dhatawesomedude

@dhatawesomedude It seems it is disappeared in the latest Angular 4+, I was using newest Angular CLI to create the projects.

hantsy avatar Aug 23 '17 06:08 hantsy