Fix routing TCP upgrades via express middleware
Currently, if there was a POST request with 'tcp' upgrade, the code just hangs and waits till timeout. Instead, let express code will give us a default 'finalhandler' which responds appropriately - https://github.com/expressjs/express/blob/master/lib/application.js#L161 https://github.com/pillarjs/finalhandler/blob/master/index.js#L57 for future reference on how to call this callback should socket.destroy need to be called.
This commit is contained in:
@@ -218,13 +218,9 @@ function initializeExpressSync() {
|
||||
'\r\n');
|
||||
};
|
||||
|
||||
// route through express middleware
|
||||
app(req, res, function (error) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
socket.destroy();
|
||||
}
|
||||
});
|
||||
// route through express middleware. if we provide no callback, express will provide a 'finalhandler'
|
||||
// TODO: it's not clear if socket needs to be destroyed
|
||||
app(req, res);
|
||||
});
|
||||
|
||||
return httpServer;
|
||||
|
||||
Reference in New Issue
Block a user