feat: warn when ipcRenderer.sendSync() called with no listeners for channel (#31432)

Co-authored-by: Milan Burda <milan.burda@gmail.com>
This commit is contained in:
trop[bot]
2021-10-21 09:09:33 +09:00
committed by GitHub
parent cef7a28136
commit 883f692dad

View File

@@ -541,6 +541,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);
}