diff --git a/apps/browser/src/platform/services/task-scheduler/background-task-scheduler.service.spec.ts b/apps/browser/src/platform/services/task-scheduler/background-task-scheduler.service.spec.ts index 110326e3d7..c9eeffe83a 100644 --- a/apps/browser/src/platform/services/task-scheduler/background-task-scheduler.service.spec.ts +++ b/apps/browser/src/platform/services/task-scheduler/background-task-scheduler.service.spec.ts @@ -68,6 +68,8 @@ describe("BackgroundTaskSchedulerService", () => { triggerPortOnDisconnectEvent(portMock); expect(backgroundTaskSchedulerService["ports"].size).toBe(0); + expect(portMock.onMessage.removeListener).toHaveBeenCalled(); + expect(portMock.onDisconnect.removeListener).toHaveBeenCalled(); }); }); diff --git a/apps/browser/src/platform/services/task-scheduler/background-task-scheduler.service.ts b/apps/browser/src/platform/services/task-scheduler/background-task-scheduler.service.ts index 6e5a857c39..23b580988f 100644 --- a/apps/browser/src/platform/services/task-scheduler/background-task-scheduler.service.ts +++ b/apps/browser/src/platform/services/task-scheduler/background-task-scheduler.service.ts @@ -41,6 +41,7 @@ export class BackgroundTaskSchedulerService extends BrowserTaskSchedulerServiceI */ private handlePortOnDisconnect = (port: chrome.runtime.Port) => { port.onMessage.removeListener(this.handlePortMessage); + port.onDisconnect.removeListener(this.handlePortOnDisconnect); this.ports.delete(port); };