Fix missing remote object error when calling remote function created in preload script (#15444)
* fix: report wrong context error based on contextId * fix: destroyed remote renderer warning is now async
This commit is contained in:
parent
b2e1a93177
commit
a8f2646ba6
5 changed files with 54 additions and 21 deletions
|
@ -350,26 +350,21 @@ ipcMain.on('disable-preload-on-next-will-attach-webview', (event, id) => {
|
|||
|
||||
ipcMain.on('try-emit-web-contents-event', (event, id, eventName) => {
|
||||
const consoleWarn = console.warn
|
||||
let warningMessage = null
|
||||
const contents = webContents.fromId(id)
|
||||
const listenerCountBefore = contents.listenerCount(eventName)
|
||||
|
||||
try {
|
||||
console.warn = (message) => {
|
||||
warningMessage = message
|
||||
}
|
||||
contents.emit(eventName, { sender: contents })
|
||||
} finally {
|
||||
console.warn = (warningMessage) => {
|
||||
console.warn = consoleWarn
|
||||
|
||||
const listenerCountAfter = contents.listenerCount(eventName)
|
||||
event.returnValue = {
|
||||
warningMessage,
|
||||
listenerCountBefore,
|
||||
listenerCountAfter
|
||||
}
|
||||
}
|
||||
|
||||
const listenerCountAfter = contents.listenerCount(eventName)
|
||||
|
||||
event.returnValue = {
|
||||
warningMessage,
|
||||
listenerCountBefore,
|
||||
listenerCountAfter
|
||||
}
|
||||
contents.emit(eventName, { sender: contents })
|
||||
})
|
||||
|
||||
ipcMain.on('handle-uncaught-exception', (event, message) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue