aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-04-17 09:51:18 +0200
committerChocobozzz <me@florianbigard.com>2023-04-17 09:51:18 +0200
commit82d1653d799ccc0bcc228bb5e5aafef7a071c2db (patch)
treedf7c1ad2aa0c130c39df422e04b164d73f4d32dd
parent208c97e111f2610880a588964bb61a03503cfcf6 (diff)
downloadPeerTube-82d1653d799ccc0bcc228bb5e5aafef7a071c2db.tar.gz
PeerTube-82d1653d799ccc0bcc228bb5e5aafef7a071c2db.tar.zst
PeerTube-82d1653d799ccc0bcc228bb5e5aafef7a071c2db.zip
Prevent crash on plugin ws error
-rw-r--r--server/lib/plugins/plugin-manager.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index c4d9b6574..d368aecfc 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -79,6 +79,10 @@ export class PluginManager implements ServerHook {
79 79
80 registerWebSocketRouter () { 80 registerWebSocketRouter () {
81 this.server.on('upgrade', (request, socket, head) => { 81 this.server.on('upgrade', (request, socket, head) => {
82 // Check if it's a plugin websocket connection
83 // No need to destroy the stream when we abort the request
84 // Other handlers in PeerTube will catch this upgrade event too (socket.io, tracker etc)
85
82 const url = request.url 86 const url = request.url
83 87
84 const matched = url.match(`/plugins/([^/]+)/([^/]+/)?ws(/.*)`) 88 const matched = url.match(`/plugins/([^/]+)/([^/]+/)?ws(/.*)`)
@@ -95,7 +99,11 @@ export class PluginManager implements ServerHook {
95 const wss = routes.find(r => r.route.startsWith(subRoute)) 99 const wss = routes.find(r => r.route.startsWith(subRoute))
96 if (!wss) return 100 if (!wss) return
97 101
98 wss.handler(request, socket, head) 102 try {
103 wss.handler(request, socket, head)
104 } catch (err) {
105 logger.error('Exception in plugin handler ' + npmName, { err })
106 }
99 }) 107 })
100 } 108 }
101 109