fix: properly disconnect websockets from task handler

This commit is contained in:
DecDuck
2024-11-16 17:27:27 +11:00
parent bc0c47c487
commit 5358f1f52c
2 changed files with 10 additions and 0 deletions

View File

@ -48,5 +48,7 @@ export default defineWebSocketHandler({
if (!peer.id) return;
if (adminSocketSessions[peer.id] === undefined) return;
delete adminSocketSessions[peer.id];
taskHandler.disconnectAll(peer.id);
},
});

View File

@ -111,6 +111,14 @@ class TaskHandler {
return true;
}
disconnectAll(id: string) {
for (const [taskId] of Object.keys(this.taskRegistry)) {
delete this.taskRegistry[taskId].clients[id];
}
delete this.clientRegistry[id];
}
disconnect(id: string, taskId: string) {
if (!this.taskRegistry[taskId]) return false;