Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I let webpack-dev-server have incoming request timeout with custom value?

I have a webpack config file with webpack-dev-server as below.

const webpack = require('webpack');

module.exports = {
    devtool: 'inline-source-map',
    devServer: {
    disableHostCheck: true,
    historyApiFallback: true,
    compress: true,
    host: '0.0.0.0',
    port: 3000,
    publicPath: '/static/js/',
    proxy: {
        '**': {
            target: 'http://localhost.idincu.net:8080',
            secure: false,
            prependPath: false,
            proxyTimeout: 1000 * 60 * 10
            }
        }
    },
    plugins: [
        new webpack.NamedModulesPlugin()
    ]
}

Now, I'm getting ECONNRESET when I sent a request to the backend server with proxy. The reason why this happened is probably setting timeout of webpack-dev-server.

And I have dug into this in order to change timeout setting of webpack-dev-server. But I have failed. Can anyone give some advice for me?

One of some ways what I have found to do it is to set timeout on express. Or if there were a way to use devServer.before property corresponding to my config file, it would be a good way for me.

Thank you in advance.

like image 262
HanByul Lee Avatar asked Oct 20 '25 22:10

HanByul Lee


1 Answers

Self answer here.

Just adding timeout: 1000 * 60 * 10 into devServer.proxy like below would make it work.

const webpack = require('webpack');

const devConfig = {
    devtool: 'inline-source-map',
    devServer: {
        disableHostCheck: true,
        historyApiFallback: true,
        compress: true,
        host: '0.0.0.0',
        port: 3000,
        publicPath: '/static/js/',
        proxy: {
            '**': {
                target: 'http://localhost.idincu.net:8080',
                secure: false,
                prependPath: false,
                proxyTimeout: 1000 * 60 * 10,
                timeout: 1000 * 60 * 10
            }
        }
    },
    plugins: [
        new webpack.NamedModulesPlugin()
    ]
};

module.exports = devConfig;
like image 155
HanByul Lee Avatar answered Oct 23 '25 22:10

HanByul Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!