electron icon indicating copy to clipboard operation
electron copied to clipboard

Javascript error on Menu Item click after page reload

Open axerosolutions opened this issue 10 years ago • 8 comments

Hi, I am building a simple one page electron app with a simple HTML page with a menu using sample code shown here: [https://github.com/atom/electron/blob/master/docs/api/menu.md]

But I am getting a javascript error on SECOND page reload on a simple electron app. Note that this error only comes if I reload the app once and then click View->Reload again.

"Uncaught exception error: Attempting to call a functions in the renderer window that has been closed or released. Function provided here: undefined".

I have even gone through this case but did not understand how to remove call back reference for my simple case. Here is the code I have in my simple HTML page:

https://jsfiddle.net/fb2a3ho6/

I would like to know why on second refresh, when reference to the old window is lost, I am getting an error.

Vivek

axerosolutions avatar Feb 02 '16 12:02 axerosolutions

This is a bug of Electron, somehow the render-view-deleted event is emitted after the page gets reloaded, making the code to clear renderer callbacks at wrong time.

zcbenz avatar Feb 02 '16 12:02 zcbenz

Not sure if this is the right forum to ask this, but any idea when this bug would be fixed?

axerosolutions avatar Feb 02 '16 13:02 axerosolutions

.. or is there any way to work around it ?

davibe avatar Feb 10 '16 07:02 davibe

I am also having the same issue. What is the workaround for this? All subsequent reload calls are also blocked in the application.

MFQ avatar Feb 10 '16 18:02 MFQ

In my case i ended up avoiding page reload. I performed the task that needed reload on a new separate window.

davibe avatar Feb 10 '16 19:02 davibe

Also having this issue. Have to disable reloading now.

zhongyi-tong avatar Feb 18 '16 19:02 zhongyi-tong

Yeah, my project is hitting the bug too. Have to use an older electron version because of this.

WriterDuet avatar Feb 21 '16 05:02 WriterDuet

I still hit this error now, electron version 1.4.8

[Window Title]
Error

[Main Instruction]
A JavaScript error occurred in the main process

[Content]
Uncaught Exception:
Error: Attempting to call a function in a renderer window that has been closed or released. Function provided here: mycard.component.js:28:28.
   at BrowserWindow.callIntoRenderer (D:\Github\mycard\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:199:19)
   at emitOne (events.js:101:20)
   at BrowserWindow.emit (events.js:188:7)

[确定]

my code around mycard.component.js:28:28:

currentWindow = remote.getCurrentWindow();
...
this.currentWindow.on('maximize', () => ...);

zh99998 avatar Nov 29 '16 09:11 zh99998