From 5592652504e9e46e84aa85c3bb0404211cc9e581 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Thu, 14 Oct 2021 20:24:04 +0200 Subject: [PATCH] feat: warn when ipcRenderer.sendSync() called with no listeners for channel (#31344) --- lib/browser/api/web-contents.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index b62ca2b9e266..8bb863a0eb21 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -593,6 +593,9 @@ WebContents.prototype._init = function () { ipcMainInternal.emit(channel, event, ...args); } else { addReplyToEvent(event); + if (this.listenerCount('ipc-message-sync') === 0 && ipcMain.listenerCount(channel) === 0) { + console.warn(`WebContents #${this.id} called ipcRenderer.sendSync() with '${channel}' channel without listeners.`); + } this.emit('ipc-message-sync', event, channel, ...args); ipcMain.emit(channel, event, ...args); }