Younghun Jung
Younghun Jung

Reputation: 361

webpack dev server proxy has an error : HPE_INVALID_CHUNK_SIZE

I use webpack-dev-server on my project. Project uses Spring boot + Tiles + Vue + webpack.

Environment:

OS: Mac OS
Node Version: 9.4.0
NPM Version: 5.6.0
Webpack Version: 4.25.1
webpack-dev-server Version: 3.1.10

In local environment, FE port use 8080 and webpack-dev-server port is 9090. Bundled files by webpack are created in /front/static-dev/build/. So, I use proxy options like below.

devServer: {
    publicPath: 'http://localhost:9090/front/static-dev/build/',
    port: 9090,
    proxy: {
        '/**': {
            target: 'http://localhost:8080',
            secure: false,
            changeOrigin: true
        }
    },
    open: true
}

After starting webpack-dev-server, static resources like (JSP, bundled js files, CSS files or image, ...) are loaded normally. However, whenever I request some api, webpack-dev-server occured same error. Error logs are like below.

[HPM] Error occurred while trying to proxy 
request /api/v1/users/name from localhost:9090 to 
http://localhost:8080 (HPE_INVALID_CHUNK_SIZE) 
(https://nodejs.org/api/errors.html#errors_common_system_errors)

After request some API, I checked logs on Eclipse and Api requests are normally being made. In Chrome Consloe log like below.

http://localhost:9090/api/v1/users/name net::ERR_CONTENT_DECODING_FAILED 502 (Bad Gateway)

I think the problems are in response part. Searching HPE_INVALID_CHUNK_SIZE with Webpack in google, I can find no information.

How can I solve this problem.

Thanks.

Upvotes: 4

Views: 5709

Answers (2)

svobol13
svobol13

Reputation: 1950

This error might be caused by wrong headers sent to your proxy. In case of any further problems you could try Transport-Encoding: chunked or set Content-Length http headers. You can see this answer https://stackoverflow.com/a/55433376/996895

Upvotes: 0

Younghun Jung
Younghun Jung

Reputation: 361

I resolve this issue using Connection options.

        proxy: {
        '/**': {
            target: 'http://localhost:8080/',
            secure: false,
            changeOrigin: true,
            headers: {
                Connection: 'keep-alive'
            }
        }

Upvotes: 11

Related Questions