Fix Peertube crash:

Peertube could crash when someone attemps to connect to Websocket endpoint during plugin initialization.
This commit is contained in:
John Livingston
2023-04-17 11:14:41 +02:00
parent aa1170a3f4
commit 310419ad66
2 changed files with 5 additions and 1 deletions

View File

@ -234,7 +234,10 @@ async function initWebchatRouter (options: RegisterServerOptionsV5): Promise<Rou
route: '/xmpp-websocket',
handler: (request, socket, head) => {
if (!currentWebsocketProxy) {
throw new Error('There is no current websocket proxy, should not get here.')
peertubeHelpers.logger.error('There is no current websocket proxy, should not get here.')
// no need to close the socket, Peertube will
// (see https://github.com/Chocobozzz/PeerTube/issues/5752#issuecomment-1510870894)
return
}
currentWebsocketProxy.ws(request, socket, head)
}