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:
parent
6c599556a2
commit
be8e350510
@ -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";
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user