Fix missing remote object error when calling remote function created in preload script (3-0-x) (#15445)

* fix: report wrong context error based on contextId

* fix: destroyed remote renderer warning is now async
This commit is contained in:
Cheng Zhao 2018-11-01 08:55:02 +09:00 committed by GitHub
parent 7b0959ed2b
commit 5c853b681c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 20 deletions

View file

@ -279,6 +279,7 @@ function metaToException (meta) {
ipcRenderer.on('ELECTRON_RENDERER_CALLBACK', (event, passedContextId, id, args) => {
if (passedContextId !== contextId) {
// The invoked callback belongs to an old page in this renderer.
ipcRenderer.send('ELECTRON_BROWSER_WRONG_CONTEXT_ERROR', contextId, passedContextId, id)
return
}
callbacksRegistry.apply(id, metaToValue(args))
@ -288,6 +289,7 @@ ipcRenderer.on('ELECTRON_RENDERER_CALLBACK', (event, passedContextId, id, args)
ipcRenderer.on('ELECTRON_RENDERER_RELEASE_CALLBACK', (event, passedContextId, id) => {
if (passedContextId !== contextId) {
// The freed callback belongs to an old page in this renderer.
ipcRenderer.send('ELECTRON_BROWSER_WRONG_CONTEXT_ERROR', contextId, passedContextId, id)
return
}
callbacksRegistry.remove(id)