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

This commit is contained in:
Milan Burda 2021-10-14 20:24:04 +02:00 committed by GitHub
parent b744707536
commit 5592652504
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}