From ecc3aa0820b5eb6892cc3a2616656d6432e935a2 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 6 May 2021 16:23:04 +0300 Subject: [PATCH] unwrap possible observables from IPC-messaging Signed-off-by: Roman --- src/common/ipc/ipc.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common/ipc/ipc.ts b/src/common/ipc/ipc.ts index 390f4b22fb..5b9adb7c85 100644 --- a/src/common/ipc/ipc.ts +++ b/src/common/ipc/ipc.ts @@ -2,19 +2,22 @@ // https://www.electronjs.org/docs/api/ipc-main // https://www.electronjs.org/docs/api/ipc-renderer -import { ipcMain, ipcRenderer, webContents, remote } from "electron"; +import { ipcMain, ipcRenderer, remote, webContents } from "electron"; import { toJS } from "mobx"; import logger from "../../main/logger"; -import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames"; +import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames"; const subFramesChannel = "ipc:get-sub-frames"; export function handleRequest(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any) { - ipcMain.handle(channel, listener); + ipcMain.handle(channel, (event: Electron.IpcMainInvokeEvent, ...args: any[]) => { + args = toJS(args); // unwrap possibly leaking observable values + return listener(event, ...args); + }); } export async function requestMain(channel: string, ...args: any[]) { - return ipcRenderer.invoke(channel, ...args); + return ipcRenderer.invoke(channel, ...toJS(args)); } function getSubFrames(): ClusterFrameInfo[] {