Fix IPC race condition.

Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
Panu Horsmalahti committed 2021-10-28 16:25:03 +03:00
1 parent 74abf474d7
commit c112be647d
1 file changed
+6 -6
+6 -6
View File
@@ -49,6 +49,12 @@ function getSubFrames(): ClusterFrameInfo[] {
}
export function broadcastMessage(channel: string, ...args: any[]) {
const subFramesP = ipcRenderer
? requestMain(subFramesChannel)
: Promise.resolve(getSubFrames());
subFramesP
.then(subFrames => {
const views: undefined | ReturnType<typeof webContents.getAllWebContents> | ReturnType<typeof remote.webContents.getAllWebContents> = (webContents || electronRemote?.webContents)?.getAllWebContents();
if (!views || !Array.isArray(views) || views.length === 0) return;
@@ -57,12 +63,6 @@ export function broadcastMessage(channel: string, ...args: any[]) {
ipcRenderer?.send(channel, ...args);
ipcMain?.emit(channel, ...args);
const subFramesP = ipcRenderer
? requestMain(subFramesChannel)
: Promise.resolve(getSubFrames());
subFramesP
.then(subFrames => {
for (const view of views) {
let viewType = "unknown";