You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The callsites of handleUpgrade do not handle errors thrown from prepareProxyRequest. For a user, this means that any error thrown in router or pathRewrite will result in an unhandledRejection.
We can see that the two call sites for handleUpgrade neither await the returned promise, nor use .catch() to handle errors:
Add a router or pathRewrite function that throws an error, then try to make a websocket request. Observe that the error is not handled. E.g., if you add an onError handler to the proxy config, it is not called, and if you process.on('unhandledRejection', (e) => console.error(e)), that error is logged.
Expected behavior (be clear and concise)
onError should be invoked so that I can handle the error appropriately.
How is http-proxy-middleware used in your project?
It is installed as a direct dependency.
What http-proxy-middleware configuration are you using?
Here's a pared-down version:
constoptions={router: async()=>{thrownewError('testing');},onError: (err,req,res)=>{// Not called for websocket requestsres.status(500).send();},};
What OS/version and node/version are you seeing the problem?
macOS 12.5.1; Node v16.17.0
The text was updated successfully, but these errors were encountered:
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
The callsites of
handleUpgrade
do not handle errors thrown fromprepareProxyRequest
. For a user, this means that any error thrown inrouter
orpathRewrite
will result in anunhandledRejection
.We can see that the two call sites for
handleUpgrade
neitherawait
the returned promise, nor use.catch()
to handle errors:http-proxy-middleware/src/http-proxy-middleware.ts
Line 34 in 79c9885
http-proxy-middleware/src/http-proxy-middleware.ts
Line 88 in 79c9885
Step-by-step reproduction instructions
Add a
router
orpathRewrite
function that throws an error, then try to make a websocket request. Observe that the error is not handled. E.g., if you add anonError
handler to the proxy config, it is not called, and if youprocess.on('unhandledRejection', (e) => console.error(e))
, that error is logged.Expected behavior (be clear and concise)
onError
should be invoked so that I can handle the error appropriately.How is http-proxy-middleware used in your project?
It is installed as a direct dependency.
What http-proxy-middleware configuration are you using?
Here's a pared-down version:
What OS/version and node/version are you seeing the problem?
macOS 12.5.1; Node v16.17.0
The text was updated successfully, but these errors were encountered: