diff --git a/lib/browser/desktop-capturer.ts b/lib/browser/desktop-capturer.ts index b1dfa5077998..885319e4296c 100644 --- a/lib/browser/desktop-capturer.ts +++ b/lib/browser/desktop-capturer.ts @@ -48,6 +48,9 @@ export const getSourcesImpl = (event: Electron.IpcMainEvent | null, args: Electr } // Remove from currentlyRunning once we resolve or reject currentlyRunning = currentlyRunning.filter(running => running.options !== options); + if (event) { + event.sender.removeListener('destroyed', stopRunning); + } }; capturer._onerror = (error: string) => { @@ -66,7 +69,7 @@ export const getSourcesImpl = (event: Electron.IpcMainEvent | null, args: Electr // reference to emit and the capturer itself so that it never dispatches // back to the renderer if (event) { - event.sender.once('destroyed', () => stopRunning()); + event.sender.once('destroyed', stopRunning); } });