question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'on' of null at catchUpgradeRequest

See original GitHub issue

Expected behavior

Able to proxy websockets with webpack 2.

Actual behavior

Not able to proxy websockets with webpack 2.

Setup

webpack-dev-server v2.2.1 was just pushed to stable. It depends on http-proxy-middleware ~0.17.1, which resolves to 0.17.3.

At the previous stable version, v1.16.2, this webpack config works:

  devServer: {
    https: true,
    proxy: {
      '/my-backend': {
        changeOrigin: true,
        pathRewrite: {'^/my-backend': ''},
        target: myBackendUrl,
        ws: true,
      },
  }

At v2.2.1, it does not. Instead I get:

TypeError: Cannot read property 'on' of null
    at catchUpgradeRequest (/work/my-project/node_modules/http-proxy-middleware/lib/index.js:56:19)
    at middleware (/work/my-project/node_modules/http-proxy-middleware/lib/index.js:48:13)
    at /work/my-project/node_modules/webpack-dev-server/lib/Server.js:223:15
    at Layer.handle [as handle_request] (/work/my-project/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/work/my-project/node_modules/express/lib/router/index.js:312:13)
    at /work/my-project/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/work/my-project/node_modules/express/lib/router/index.js:330:12)
    at next (/work/my-project/node_modules/express/lib/router/index.js:271:10)
    at middleware (/work/my-project/node_modules/http-proxy-middleware/lib/index.js:43:13)
    at /work/my-project/node_modules/webpack-dev-server/lib/Server.js:223:15
    at Layer.handle [as handle_request] (/work/my-project/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/work/my-project/node_modules/express/lib/router/index.js:312:13)
    at /work/my-project/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/work/my-project/node_modules/express/lib/router/index.js:330:12)
    at next (/work/my-project/node_modules/express/lib/router/index.js:271:10)
    at goNext (/work/my-project/node_modules/webpack-dev-middleware/middleware.js:28:49)

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
tonygentilcorecommented, Jan 31, 2017

Nice, I can confirm that this config gets me going again!

  devServer: {
    https: {
      spdy: {
        protocols: ['http/1.1'],
      },
    },
    proxy: {
      '/my-backend': {
        changeOrigin: true,
        pathRewrite: {'^/my-backend': ''},
        target: myBackendUrl,
        ws: true,
      },
    },
  }
0reactions
dhergescommented, May 12, 2017

Hi, we’re using thru @angular/cli 1.0.2 default set up … what they pull in. Would need to look at exact version next week in office.

Cheers, David

On 12. May 2017, at 17:33, chimurai notifications@github.com wrote:

Too bad the fix didn’t work…

Are you using the latest version of webpack-dev-server? And can you share your devServer config?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - TypeError: Cannot read property 'on' of null at ...
Able to proxy websockets with webpack 2. Actual behavior. Not able to proxy websockets with webpack 2. Setup. webpack-dev-server v2.2.1 was just pushed...
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
This will result in Uncaught TypeError: Cannot read property 'value' of null . The reason will be that the element with id input...
Read more >
Uncaught TypeError: Cannot read property 'on' of null [duplicate]
In your code, $ is used by prototype, $('.addtocart') is returning null as there are no elements with class .addtocart when this script...
Read more >
TypeError: Cannot read property 'cancelled' of null - Browser
Hi, I am getting this error: nr-spa-1173.min.js:formatted:1883 Uncaught TypeError: Cannot read property 'cancelled' of null at u.dt.finish ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found