mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 05:05:39 +00:00
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:
@@ -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`);
|
||||
|
||||
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user