Skip to content
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

Server Crashed after [HPM] Upgrading to WebSocket socket error #777

Open
2 tasks done
whatwewant opened this issue May 9, 2022 · 7 comments · May be fixed by #778
Open
2 tasks done

Server Crashed after [HPM] Upgrading to WebSocket socket error #777

whatwewant opened this issue May 9, 2022 · 7 comments · May be fixed by #778

Comments

@whatwewant
Copy link

Checks

Describe the bug (be clear and concise)

10531652080005_ pic

Step-by-step reproduction instructions

1. Proxy Websocket Broken

Expected behavior (be clear and concise)

Server not crashed, just log errors

How is http-proxy-middleware used in your project?

const { createProxyMiddleware } = require('http-proxy-middleware');

...
createProxyMiddleware({
  target: `http://127.0.0.1:${this.port}/`,
  changeOrigin: true,
  ws: true,
  router: (req) => {
    const url = req.url;
    if (url.startsWith('/xxx')) {
      return null;
    }
    const result = this.router(url, this.url, this.port);
    if (result) {
      return result;
    }
    if (url.startsWith('/v1')) {
      return this.url;
    }
    return `http://127.0.0.1:${this.port}/`;
  },
})
...


### What http-proxy-middleware configuration are you using?

```typescript
{
  target: `http://127.0.0.1:${this.port}/`,
  changeOrigin: true,
  ws: true,
  router: (req) => {
    const url = req.url;
    if (url.startsWith('/xxx')) {
      return null;
    }
    const result = this.router(url, this.url, this.port);
    if (result) {
      return result;
    }
    if (url.startsWith('/v1')) {
      return this.url;
    }
    return `http://127.0.0.1:${this.port}/`;
  },
}


### What OS/version and node/version are you seeing the problem?

```shell
Platform: darwin
Architecture: arm64
Kernal: 21.3.0
Node: v16.14.2
V8: 9.4.146.24-node.20
NPM: 6.14.16
Yarn: 1.22.18

Additional context (optional)

No response

@whatwewant
Copy link
Author

related: #733

@whatwewant
Copy link
Author

how to: just

this.proxy.ws(req, socket, head, activeProxyOptions, this.logError); 

@whatwewant
Copy link
Author

found latest source code, should change this.logError

whatwewant added a commit to whatwewant/http-proxy-middleware that referenced this issue May 9, 2022
@chimurai
Copy link
Owner

chimurai commented May 9, 2022

Hi. Thanks for reporting.

Could you try with http-proxy-middleware@beta? (v3.0.0-beta.0)

V3 registered some additional error handlers to catch the uncaught errors.
(https://github.com/chimurai/http-proxy-middleware/blob/master/src/plugins/default/debug-proxy-errors-plugin.ts)

Hopefully it's already fixed in V3

@whatwewant
Copy link
Author

Hi. Thanks for reporting.

Could you try with http-proxy-middleware@beta? (v3.0.0-beta.0)

V3 registered some additional error handlers to catch the uncaught errors. (https://github.com/chimurai/http-proxy-middleware/blob/master/src/plugins/default/debug-proxy-errors-plugin.ts)

Hopefully it's already fixed in V3

thanks for reply, i will try it later

@shekharramola
Copy link

It is coming in beta too

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

Successfully merging a pull request may close this issue.

3 participants