fix: memory leak in desktopCapturer.getSources (#27031) (#27506)

Co-authored-by: Jeremy Rose <jeremya@chromium.org>
This commit is contained in:
Milan Burda
2021-01-27 09:02:17 +01:00
committed by GitHub
parent 35dfdfc901
commit 39bea9a328

View File

@@ -28,6 +28,7 @@ export const getSources = (event: Electron.IpcMainEvent, options: ElectronIntern
}
// Remove from currentlyRunning once we resolve or reject
currentlyRunning = currentlyRunning.filter(running => running.options !== options);
event.sender.removeListener('destroyed', stopRunning);
};
const emitter = new EventEmitter();
@@ -54,7 +55,7 @@ export const getSources = (event: Electron.IpcMainEvent, options: ElectronIntern
// If the WebContents is destroyed before receiving result, just remove the
// reference to emit and the capturer itself so that it never dispatches
// back to the renderer
event.sender.once('destroyed', () => stopRunning());
event.sender.once('destroyed', stopRunning);
});
currentlyRunning.push({