Skip to content

Commit

Permalink
chore(app): make renderer#send fail-safe
Browse files Browse the repository at this point in the history
Ensure we don't fail with an app error once the main window is closed.

Related to #4474 (comment)
  • Loading branch information
nikku committed Aug 26, 2024
1 parent ebea963 commit d9f7c5b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/lib/util/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const {
} = require('min-dash');


const log = require('../log')('app:renderer');

function on(event, callback, that) {

ipcMain.on(event, function(evt, id, args) {
Expand Down Expand Up @@ -65,6 +67,12 @@ module.exports.onSync = onSync;
function send() {
var args = Array.prototype.slice.call(arguments);

if (!app.mainWindow) {
log.warn('trying to send to non-existing client window', args[0]);

return;
}

app.mainWindow.webContents.send.apply(app.mainWindow.webContents, args);
}

Expand Down

0 comments on commit d9f7c5b

Please sign in to comment.