From eb35d413210a0e9dc19a834b5a7db1bb709a95eb Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Fri, 23 Jun 2023 11:51:01 +0500 Subject: [PATCH] desktop: fix "object has been destoryed" error --- apps/desktop/package-lock.json | 2 +- apps/desktop/package.json | 2 +- .../desktop/patches/electron-trpc+0.5.2.patch | 23 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 apps/desktop/patches/electron-trpc+0.5.2.patch diff --git a/apps/desktop/package-lock.json b/apps/desktop/package-lock.json index 00deacf78..897f8739d 100644 --- a/apps/desktop/package-lock.json +++ b/apps/desktop/package-lock.json @@ -12,7 +12,7 @@ "@trpc/client": "^10.29.1", "@trpc/server": "^10.29.1", "diary": "^0.3.1", - "electron-trpc": "^0.5.0", + "electron-trpc": "^0.5.2", "electron-updater": "^5.3.0", "icojs": "^0.17.1", "typed-emitter": "^2.1.0", diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 52bcb1087..7b13f2e2e 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -15,7 +15,7 @@ "@trpc/client": "^10.29.1", "@trpc/server": "^10.29.1", "diary": "^0.3.1", - "electron-trpc": "^0.5.0", + "electron-trpc": "^0.5.2", "electron-updater": "^5.3.0", "icojs": "^0.17.1", "typed-emitter": "^2.1.0", diff --git a/apps/desktop/patches/electron-trpc+0.5.2.patch b/apps/desktop/patches/electron-trpc+0.5.2.patch new file mode 100644 index 000000000..d00fa3f35 --- /dev/null +++ b/apps/desktop/patches/electron-trpc+0.5.2.patch @@ -0,0 +1,23 @@ +diff --git a/node_modules/electron-trpc/dist/main.mjs b/node_modules/electron-trpc/dist/main.mjs +index 379cf3b..2644e5d 100644 +--- a/node_modules/electron-trpc/dist/main.mjs ++++ b/node_modules/electron-trpc/dist/main.mjs +@@ -221,9 +221,16 @@ class G { + i(this, c).includes(r) || (i(this, c).push(r), I(this, T, W).call(this, r)); + } + detachWindow(r) { ++ + y(this, c, i(this, c).filter((n) => n !== r)); +- for (const [n, t] of i(this, u).entries()) +- n.startsWith(`${r.webContents.id}-`) && (t.unsubscribe(), i(this, u).delete(n)); ++ for (const [n, t] of i(this, u).entries()) { ++ try { ++ n.startsWith(`${r.webContents.id}-`) && (t.unsubscribe(), i(this, u).delete(n)); ++ } catch(e) { ++ console.error(e); ++ // ignore ++ } ++ } + } + } + c = new WeakMap(), u = new WeakMap(), T = new WeakSet(), W = function(r) {