Skip to content

v4.0.0-beta.0: dev server fails in multiple configs env with proxy property. #2891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
sprilukin opened this issue Dec 1, 2020 · 3 comments · Fixed by #2905
Closed
1 of 2 tasks

v4.0.0-beta.0: dev server fails in multiple configs env with proxy property. #2891

sprilukin opened this issue Dec 1, 2020 · 3 comments · Fixed by #2905

Comments

@sprilukin
Copy link

  • Operating System: OSX 10.14.6
  • Node Version: v14.15.1
  • NPM Version: 6.14.8
  • webpack Version: 5.9.0
  • webpack-dev-server Version: v4.0.0-beta.0
  • Browser: any
  • This is a bug
  • This is a modification request

Code

checkout repo: [email protected]:sprilukin/webpack-dev-server-beta4-proxy-issue.git
or use these code snippets:

// webpack.config.js
module.exports = [
    {
        entry: {
            'entry1': './src/entry1'
        },
        devServer: {
            proxy: {
                '*': {
                    target: "http://localhost:8080",
                    bypass: function (req) {
                        return req.url;
                    }
                }
            }
        }
    },
    {
        entry: {
            'entry2': './src/entry2'
        }
    }
];
// ./src/entry1
console.log("Entry 1");
// ./src/entry2
console.log("Entry 2");

Expected Behavior

dev server started successfully

Actual Behavior

There is an error in the console during starting dev server:

(node:8289) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'level' of undefined
    at /Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:203:57
    at Array.map (<anonymous>)
    at Server.setupProxyFeature (/Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:169:62)
    at Object.proxy (/Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:369:16)
    at /Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:449:24
    at Array.forEach (<anonymous>)
    at Server.setupFeatures (/Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:448:22)
    at new Server (/Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/webpack-dev-server/lib/Server.js:68:10)
    at /Users/sergey/work/my/js/webpack-dev-server-proxy-issue/node_modules/@webpack-cli/serve/lib/startDevServer.js:34:24
    at Array.forEach (<anonymous>)

For Bugs; How can we reproduce the behavior?

  • chekcout this repo [email protected]:sprilukin/webpack-dev-server-beta4-proxy-issue.git
  • npm install && npm run start

Here is the piece of code where exception is actually thrown:

          proxyOptions.logLevel = getLogLevelForProxy(
            this.compiler.options.infrastructureLogging.level
          );

Here this.compiler.options is an Array, not an Object in case of multiple webpack config env.

@alexander-akait
Copy link
Member

Yep, bug

@sethomas
Copy link

sethomas commented Dec 1, 2020

b0161e9#r44676178

@phaberest
Copy link

phaberest commented Jan 7, 2021

I still get the same issue, has this fix been tagged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants