fix: async fns calls window.send after the window is destroyed (#6747)

* fix: app crash error

* fix: prevent app crash by ensuring window and webContents are not destroyed before sending messages
This commit is contained in:
sanish chirayath
2026-01-29 15:43:04 +05:30
committed by GitHub
parent b3a66e9c3c
commit 4b724ebd85
2 changed files with 2 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ const getProtobufIncludeDirs = (collection) => {
*/
const registerGrpcEventHandlers = (window) => {
const sendEvent = (eventName, ...args) => {
if (window && window.webContents) {
if (window && !window.isDestroyed() && window.webContents && !window.webContents.isDestroyed()) {
window.webContents.send(eventName, ...args);
} else {
console.warn(`Unable to send message "${eventName}": Window not available`);

View File

@@ -290,7 +290,7 @@ let wsClient;
*/
const registerWsEventHandlers = (window) => {
const sendEvent = (eventName, ...args) => {
if (window && window.webContents) {
if (window && !window.isDestroyed() && window.webContents && !window.webContents.isDestroyed()) {
window.webContents.send(eventName, ...args);
} else {
console.warn(`Unable to send message "${eventName}": Window not available`);