1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix IPC race condition. (#4169)

Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
Panu Horsmalahti 2021-10-28 18:46:16 +03:00 committed by GitHub
parent 6c599556a2
commit be8e350510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,20 +49,20 @@ function getSubFrames(): ClusterFrameInfo[] {
} }
export function broadcastMessage(channel: string, ...args: any[]) { export function broadcastMessage(channel: string, ...args: any[]) {
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;
args = args.map(sanitizePayload);
ipcRenderer?.send(channel, ...args);
ipcMain?.emit(channel, ...args);
const subFramesP = ipcRenderer const subFramesP = ipcRenderer
? requestMain(subFramesChannel) ? requestMain(subFramesChannel)
: Promise.resolve(getSubFrames()); : Promise.resolve(getSubFrames());
subFramesP subFramesP
.then(subFrames => { .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;
args = args.map(sanitizePayload);
ipcRenderer?.send(channel, ...args);
ipcMain?.emit(channel, ...args);
for (const view of views) { for (const view of views) {
let viewType = "unknown"; let viewType = "unknown";