New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Error remote.js #7351

Closed
paul321 opened this Issue Sep 26, 2016 · 76 comments

Comments

Projects
None yet
@paul321

paul321 commented Sep 26, 2016

  • Electron version: 1.3.5 - 1.4.1
  • Operating system: MacOS

I keep getting this error if i start the app with dev tools open and then hit refresh, from the second time it keeps showing this error and i don't know why happens, first time when i run the app everything is ok. This doesn't happen in 1.2.6

remote.js:217 Uncaught Error: Cannot read property 'object' of undefined
TypeError: Cannot read property 'object' of undefined
    at ObjectsRegistry.get (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/objects-registry.js:44:28)
    at EventEmitter.<anonymous> (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:306:31)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:219:13)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)

And after the first run the app is full of another error

remote.js:209 Uncaught (in promise) Error: Cannot read property 'object' of undefined
TypeError: Cannot read property 'object' of undefined
    at ObjectsRegistry.get (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/objects-registry.js:44:28)
    at EventEmitter.<anonymous> (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:305:31)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:218:13)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
    at ObjectsRegistry.get (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/objects-registry.js:44:28)
    at EventEmitter.<anonymous> (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:305:31)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:218:13)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
    at metaToValue (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:209:13)
    at remoteMemberFunction (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:110:18)
    at 
@bengotow

This comment has been minimized.

Show comment
Hide comment
@bengotow

bengotow Sep 26, 2016

Contributor

Hey! We're also seeing this when running the spec suite for N1. Seems to have just started happening in Electron 1.4.1.

Contributor

bengotow commented Sep 26, 2016

Hey! We're also seeing this when running the spec suite for N1. Seems to have just started happening in Electron 1.4.1.

@MarshallOfSound

This comment has been minimized.

Show comment
Hide comment
@MarshallOfSound

MarshallOfSound Sep 26, 2016

Member

Can confirm, I've been hitting this as well

Member

MarshallOfSound commented Sep 26, 2016

Can confirm, I've been hitting this as well

@MarshallOfSound

This comment has been minimized.

Show comment
Hide comment
@MarshallOfSound

MarshallOfSound Sep 26, 2016

Member

Woops, wrong button :(

Member

MarshallOfSound commented Sep 26, 2016

Woops, wrong button :(

@bengotow

This comment has been minimized.

Show comment
Hide comment
@bengotow

bengotow Sep 26, 2016

Contributor

Looks like some sort of call to a cleaned-up object through remote — I wonder if it'd be a good idea to add method and args to these error messages so it'd be a bit easier to track down: https://github.com/electron/electron/blob/master/lib/browser/rpc-server.js#L306

Contributor

bengotow commented Sep 26, 2016

Looks like some sort of call to a cleaned-up object through remote — I wonder if it'd be a good idea to add method and args to these error messages so it'd be a bit easier to track down: https://github.com/electron/electron/blob/master/lib/browser/rpc-server.js#L306

@jhgg

This comment has been minimized.

Show comment
Hide comment
@jhgg

jhgg Sep 27, 2016

We're seeing this exact same exception too. Happens when we use ctrl + R to reload the app.

remote.js:176 Uncaught Error: Cannot read property 'object' of undefined
TypeError: Cannot read property 'object' of undefined
    at ObjectsRegistry.get (/Applications/Discord Canary.app/Contents/Resources/electron.asar/browser/objects-registry.js:44:28)
    at EventEmitter.<anonymous> (/Applications/Discord Canary.app/Contents/Resources/electron.asar/browser/rpc-server.js:305:31)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Applications/Discord Canary.app/Contents/Resources/electron.asar/browser/api/web-contents.js:218:13)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)

jhgg commented Sep 27, 2016

We're seeing this exact same exception too. Happens when we use ctrl + R to reload the app.

remote.js:176 Uncaught Error: Cannot read property 'object' of undefined
TypeError: Cannot read property 'object' of undefined
    at ObjectsRegistry.get (/Applications/Discord Canary.app/Contents/Resources/electron.asar/browser/objects-registry.js:44:28)
    at EventEmitter.<anonymous> (/Applications/Discord Canary.app/Contents/Resources/electron.asar/browser/rpc-server.js:305:31)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Applications/Discord Canary.app/Contents/Resources/electron.asar/browser/api/web-contents.js:218:13)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Sep 27, 2016

Contributor

@paul321 @jhgg is this happening consistently or intermittently? Would it be possible to get the app you are seeing this on so I can try and debug it with a custom build? Thanks.

Contributor

kevinsawicki commented Sep 27, 2016

@paul321 @jhgg is this happening consistently or intermittently? Would it be possible to get the app you are seeing this on so I can try and debug it with a custom build? Thanks.

@kevinsawicki kevinsawicki added the bug label Sep 27, 2016

@jhgg

This comment has been minimized.

Show comment
Hide comment
@jhgg

jhgg Sep 27, 2016

Yeah. Just download Discord https://discordapp.com/download - pop open the inspector (cmd shift i) - hit ctrl - r a few times and it should happen. Definitely not seeing a 100% repro on it though. Sometimes it happens, others it doesn't. Sometimes hitting Ctrl+R again after the exception happens will cause it to refresh properly.

jhgg commented Sep 27, 2016

Yeah. Just download Discord https://discordapp.com/download - pop open the inspector (cmd shift i) - hit ctrl - r a few times and it should happen. Definitely not seeing a 100% repro on it though. Sometimes it happens, others it doesn't. Sometimes hitting Ctrl+R again after the exception happens will cause it to refresh properly.

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Sep 27, 2016

Contributor

@jhgg should I use the PTB version? Are you ever seeing it when refreshing the login screen or should I log in?

Contributor

kevinsawicki commented Sep 27, 2016

@jhgg should I use the PTB version? Are you ever seeing it when refreshing the login screen or should I log in?

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Sep 27, 2016

Contributor

I can reproduce this by running the N1 test suite, the failing line is remote.process.stdout.write(str) in their spec runner.

This looks to happen intermittently when a ELECTRON_BROWSER_DEREFERENCE fires for the stdout property while it is being accessed.

So the order I'm seeing is:

  • ELECTRON_BROWSER_MEMBER_GET fires from renderer to main process for the stdout property.
  • The main process replies with the metadata information and the id of the object from the cache.
  • Before the renderer process receives the reply, a ELECTRON_BROWSER_DEREFERENCE fires for the stdout property clearing it from the cache.
  • When the renderer process receives the metadata and builds up the remote object, it is now using a cache id that is no longer present in the cache so the when write is called on the stdout remote property, it fails to obtain the stdout object from the object cache for the previously returned id.

I can only reproduce this maybe once out of every 20 times tried so it seems to be dependent on a GC run happening at a specific time where the main process is building the metadata for the remote object and the renderer process runs the destructor for it.

Contributor

kevinsawicki commented Sep 27, 2016

I can reproduce this by running the N1 test suite, the failing line is remote.process.stdout.write(str) in their spec runner.

This looks to happen intermittently when a ELECTRON_BROWSER_DEREFERENCE fires for the stdout property while it is being accessed.

So the order I'm seeing is:

  • ELECTRON_BROWSER_MEMBER_GET fires from renderer to main process for the stdout property.
  • The main process replies with the metadata information and the id of the object from the cache.
  • Before the renderer process receives the reply, a ELECTRON_BROWSER_DEREFERENCE fires for the stdout property clearing it from the cache.
  • When the renderer process receives the metadata and builds up the remote object, it is now using a cache id that is no longer present in the cache so the when write is called on the stdout remote property, it fails to obtain the stdout object from the object cache for the previously returned id.

I can only reproduce this maybe once out of every 20 times tried so it seems to be dependent on a GC run happening at a specific time where the main process is building the metadata for the remote object and the renderer process runs the destructor for it.

@adamwoodnz

This comment has been minimized.

Show comment
Hide comment
@adamwoodnz

adamwoodnz Sep 28, 2016

We're also getting this on 1.3.3

We're also getting this on 1.3.3

@jhgg

This comment has been minimized.

Show comment
Hide comment
@jhgg

jhgg Sep 28, 2016

@kevinsawicki both should work - they are on the same version of Electron now. Based on your findings above - I guess it'd only work when you log in and we start interfacing with remote objects.

jhgg commented Sep 28, 2016

@kevinsawicki both should work - they are on the same version of Electron now. Based on your findings above - I guess it'd only work when you log in and we start interfacing with remote objects.

@zcbenz

This comment has been minimized.

Show comment
Hide comment
@zcbenz

zcbenz Oct 3, 2016

Contributor

It seems that the reference chain is broken, write should reference stdout, it probably referenced process instead.

Contributor

zcbenz commented Oct 3, 2016

It seems that the reference chain is broken, write should reference stdout, it probably referenced process instead.

@zcbenz

This comment has been minimized.

Show comment
Hide comment
@zcbenz

zcbenz Oct 4, 2016

Contributor

I'm wondering whether we have met a bug of V8, for the remote.process.stdout.write(str) call, it works like this underlying:

  1. send GLOBAL message to get process
  2. send MEMBER_GET message to get stdout from process
  3. send MEMBER_CALL message to call write from stdout

And the bug happens for either step 2) or 3), when process is garbage collected before process.stdout is called, or when process.stdout is garbage collected before process.stdout.write is called.

So for the expression xxx.yyy, it is possible that the xxx can be garbage collected when xxx.yyy is being called. This only happens when yyy is defined via Object.defineProperty.

Contributor

zcbenz commented Oct 4, 2016

I'm wondering whether we have met a bug of V8, for the remote.process.stdout.write(str) call, it works like this underlying:

  1. send GLOBAL message to get process
  2. send MEMBER_GET message to get stdout from process
  3. send MEMBER_CALL message to call write from stdout

And the bug happens for either step 2) or 3), when process is garbage collected before process.stdout is called, or when process.stdout is garbage collected before process.stdout.write is called.

So for the expression xxx.yyy, it is possible that the xxx can be garbage collected when xxx.yyy is being called. This only happens when yyy is defined via Object.defineProperty.

@fantasticsid

This comment has been minimized.

Show comment
Hide comment
@fantasticsid

fantasticsid Oct 8, 2016

so the workaround for now would be avoid remote calls and only use IPC messages?

so the workaround for now would be avoid remote calls and only use IPC messages?

@Eugeny

This comment has been minimized.

Show comment
Hide comment
@Eugeny

Eugeny Oct 8, 2016

@fantasticsid it seems that if the bug doesn't happen in the first second during webcontents load, it never happens later even if you use remote calls.

Eugeny commented Oct 8, 2016

@fantasticsid it seems that if the bug doesn't happen in the first second during webcontents load, it never happens later even if you use remote calls.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Oct 8, 2016

Yes when you load the app first time it doesn't happen, only after you
refresh it by using ctrl+r or cmd+r

On Oct 8, 2016 2:24 PM, "Eugene Pankov" notifications@github.com wrote:

@fantasticsid https://github.com/fantasticsid it seems that if the bug
doesn't happen in the first second during webcontents load, it never
happens later.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7351 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAh57szh7-OCOg5UhAYjBtEW9a1y3RGIks5qx31YgaJpZM4KGsBN
.

paul321 commented Oct 8, 2016

Yes when you load the app first time it doesn't happen, only after you
refresh it by using ctrl+r or cmd+r

On Oct 8, 2016 2:24 PM, "Eugene Pankov" notifications@github.com wrote:

@fantasticsid https://github.com/fantasticsid it seems that if the bug
doesn't happen in the first second during webcontents load, it never
happens later.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7351 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAh57szh7-OCOg5UhAYjBtEW9a1y3RGIks5qx31YgaJpZM4KGsBN
.

@Eugeny

This comment has been minimized.

Show comment
Hide comment
@Eugeny

Eugeny Oct 8, 2016

In my case, ctrl-r actually "fixes" the issue, i.e. the app reloads without errors.
So in short, I have a ~10% chance of the abovementioned crash when [re]loading the app, but if it happens, reloading it again always helps.

Eugeny commented Oct 8, 2016

In my case, ctrl-r actually "fixes" the issue, i.e. the app reloads without errors.
So in short, I have a ~10% chance of the abovementioned crash when [re]loading the app, but if it happens, reloading it again always helps.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Oct 8, 2016

Just the opposite case for me

On Oct 8, 2016 3:51 PM, "Eugene Pankov" notifications@github.com wrote:

In my case, ctrl-r actually "fixes" the issue, i.e. the app reloads
without errors.
So in short, I have a ~10% chance of the abovementioned crash when
[re]loading the app, but if it happens, reloading it again always helps.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7351 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAh57ngYYHzGaQ_dzkDLN8O_01OlMpjsks5qx5HbgaJpZM4KGsBN
.

paul321 commented Oct 8, 2016

Just the opposite case for me

On Oct 8, 2016 3:51 PM, "Eugene Pankov" notifications@github.com wrote:

In my case, ctrl-r actually "fixes" the issue, i.e. the app reloads
without errors.
So in short, I have a ~10% chance of the abovementioned crash when
[re]loading the app, but if it happens, reloading it again always helps.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7351 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAh57ngYYHzGaQ_dzkDLN8O_01OlMpjsks5qx5HbgaJpZM4KGsBN
.

@KochiyaOcean

This comment has been minimized.

Show comment
Hide comment
@KochiyaOcean

KochiyaOcean Oct 8, 2016

It sometimes occurs on a webview that have run several hours. All methods of webview (such as refresh, forward, getURL, etc) will return this Error

image

KochiyaOcean commented Oct 8, 2016

It sometimes occurs on a webview that have run several hours. All methods of webview (such as refresh, forward, getURL, etc) will return this Error

image

@Eugeny

This comment has been minimized.

Show comment
Hide comment
@Eugeny

Eugeny Oct 10, 2016

@zcbenz not sure if I'm doing it right, but I tried to get and keep a global reference to process in the main process and remote.process in the renderer process to prevent them from being GCed, but it didn't help.

Eugeny commented Oct 10, 2016

@zcbenz not sure if I'm doing it right, but I tried to get and keep a global reference to process in the main process and remote.process in the renderer process to prevent them from being GCed, but it didn't help.

@vojtatranta

This comment has been minimized.

Show comment
Hide comment
@vojtatranta

vojtatranta Oct 11, 2016

Please please guy, our customers are very angry with this.

Could you not just do something so that in would not throw such errors?

This line: https://github.com/electron/electron/blob/master/lib/browser/objects-registry.js#L44

Is the root of the evil by itself. Yeah I know, there should be object with this id and it should have property object but apparantly. There is a bug?

What if we just ifed it out and set logging there so we would know more? Thanks!

@zcbenz thanks!

Please please guy, our customers are very angry with this.

Could you not just do something so that in would not throw such errors?

This line: https://github.com/electron/electron/blob/master/lib/browser/objects-registry.js#L44

Is the root of the evil by itself. Yeah I know, there should be object with this id and it should have property object but apparantly. There is a bug?

What if we just ifed it out and set logging there so we would know more? Thanks!

@zcbenz thanks!

@petrbrzek

This comment has been minimized.

Show comment
Hide comment
@petrbrzek

petrbrzek Nov 1, 2016

Any news about this one?

Any news about this one?

@fantasticsid

This comment has been minimized.

Show comment
Hide comment
@fantasticsid

fantasticsid Nov 1, 2016

@vojtatranta ifing things out will just make things worse in the future

@vojtatranta ifing things out will just make things worse in the future

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 3, 2016

Any news?
We can't really use the latest builds of Electron

paul321 commented Nov 3, 2016

Any news?
We can't really use the latest builds of Electron

@Eugeny

This comment has been minimized.

Show comment
Hide comment
@Eugeny

Eugeny Nov 3, 2016

@paul it seems to go away when running the production (i.e. built with electron-builder) version of my app. As for the development, I'm just restarting the app when it crashes :(

Eugeny commented Nov 3, 2016

@paul it seems to go away when running the production (i.e. built with electron-builder) version of my app. As for the development, I'm just restarting the app when it crashes :(

@Eugeny

This comment has been minimized.

Show comment
Hide comment
@Eugeny

Eugeny Nov 3, 2016

@fantasticsid it's still better than the framework being unusable in some cases. Just if it out and spit out a warning instead. This way you can have working software AND fix it for real later.

Eugeny commented Nov 3, 2016

@fantasticsid it's still better than the framework being unusable in some cases. Just if it out and spit out a warning instead. This way you can have working software AND fix it for real later.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 3, 2016

In production you never get this error because the user never CTRL+R or CMD+R so there is no refresh :)

paul321 commented Nov 3, 2016

In production you never get this error because the user never CTRL+R or CMD+R so there is no refresh :)

@petrbrzek

This comment has been minimized.

Show comment
Hide comment
@petrbrzek

petrbrzek Nov 3, 2016

I wonder if this (https://github.com/paulcbetts/electron-remote) would help to prevent the issue. @paulcbetts

I wonder if this (https://github.com/paulcbetts/electron-remote) would help to prevent the issue. @paulcbetts

@Eugeny

This comment has been minimized.

Show comment
Hide comment
@Eugeny

Eugeny Nov 3, 2016

@paul321 well, first, I do (own hotkey handler) and, second, the bug does also happen on the first app load sometimes.

Eugeny commented Nov 3, 2016

@paul321 well, first, I do (own hotkey handler) and, second, the bug does also happen on the first app load sometimes.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 3, 2016

So we are stuck on 1.2.6 because from 1.3.0+ Electron is useless for development :(

On Nov 3, 2016 12:31 PM, "Eugene Pankov" notifications@github.com wrote:

@paul321 https://github.com/paul321 well, first, I do (own hotkey
handler) and, second, the bug does also happen on the first app load
sometimes.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7351 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAh57om-2Mp_69k1EhHJ_Fkq0m0qhK50ks5q6bgNgaJpZM4KGsBN
.

paul321 commented Nov 3, 2016

So we are stuck on 1.2.6 because from 1.3.0+ Electron is useless for development :(

On Nov 3, 2016 12:31 PM, "Eugene Pankov" notifications@github.com wrote:

@paul321 https://github.com/paul321 well, first, I do (own hotkey
handler) and, second, the bug does also happen on the first app load
sometimes.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7351 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAh57om-2Mp_69k1EhHJ_Fkq0m0qhK50ks5q6bgNgaJpZM4KGsBN
.

@albertotagliavini

This comment has been minimized.

Show comment
Hide comment
@albertotagliavini

albertotagliavini Nov 4, 2016

In the piece of code that fails with this error, do you use the api remote.getGlobal(name) to call the remote function or you use the remote.require(module) api??

Because i have seen that changing the implementation, i'm getting no errors.
Before i had a module in global in the main process and i was obtaining it in the renderer process with remote.getGlobal(name) and sometimes i was getting the same error you are talking about.

Now i have changed my code and i'm calling the remote module by remote.require(module).
It seems that i'm getting no errors.
I'm using Electron 1.4.1

albertotagliavini commented Nov 4, 2016

In the piece of code that fails with this error, do you use the api remote.getGlobal(name) to call the remote function or you use the remote.require(module) api??

Because i have seen that changing the implementation, i'm getting no errors.
Before i had a module in global in the main process and i was obtaining it in the renderer process with remote.getGlobal(name) and sometimes i was getting the same error you are talking about.

Now i have changed my code and i'm calling the remote module by remote.require(module).
It seems that i'm getting no errors.
I'm using Electron 1.4.1

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 4, 2016

I'm using it this way:
var app = require('electron').remote.app;

Can you give us an example from our perspective?

paul321 commented Nov 4, 2016

I'm using it this way:
var app = require('electron').remote.app;

Can you give us an example from our perspective?

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 22, 2016

Ok thank you, will keep you posted if i can get more info from 1.4.8

paul321 commented Nov 22, 2016

Ok thank you, will keep you posted if i can get more info from 1.4.8

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Nov 23, 2016

Contributor

Ok thank you, will keep you posted if i can get more info from 1.4.8

1.4.8 is now available.

Contributor

kevinsawicki commented Nov 23, 2016

Ok thank you, will keep you posted if i can get more info from 1.4.8

1.4.8 is now available.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 23, 2016

Here is the error, call is made from this line

App.win = require('electron').remote.getCurrentWindow();

setTimeout(function() {
      App.win.show();
}, 300);

Uncaught Error: Cannot call function 'show' on missing remote object 10
Error: Cannot call function 'show' on missing remote object 10
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\api\web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)

paul321 commented Nov 23, 2016

Here is the error, call is made from this line

App.win = require('electron').remote.getCurrentWindow();

setTimeout(function() {
      App.win.show();
}, 300);

Uncaught Error: Cannot call function 'show' on missing remote object 10
Error: Cannot call function 'show' on missing remote object 10
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\api\web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 23, 2016

Another one

Uncaught (in promise) Error: Cannot call function 'getPath' on missing remote object 18
Error: Cannot call function 'getPath' on missing remote object 18
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\api\web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents.

paul321 commented Nov 23, 2016

Another one

Uncaught (in promise) Error: Cannot call function 'getPath' on missing remote object 18
Error: Cannot call function 'getPath' on missing remote object 18
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\api\web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 23, 2016

It seems i cannot call remote functions from render process, even if i put a break point at that line, dev tools console will show me that setProgressBar it's a function

Uncaught (in promise) Error: Cannot call function 'setProgressBar' on missing remote object 41
Error: Cannot call function 'setProgressBar' on missing remote object 41
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\api\web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\api\web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
at metaToValue (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\renderer\api\remote.js:217:13)
at remoteMemberFunction (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\renderer\api\remote.js:113:18)

paul321 commented Nov 23, 2016

It seems i cannot call remote functions from render process, even if i put a break point at that line, dev tools console will show me that setProgressBar it's a function

Uncaught (in promise) Error: Cannot call function 'setProgressBar' on missing remote object 41
Error: Cannot call function 'setProgressBar' on missing remote object 41
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\api\web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
at throwRPCError (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:143:17)
at EventEmitter. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\browser\api\web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
at metaToValue (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\renderer\api\remote.js:217:13)
at remoteMemberFunction (D:\devel\work\js\desktop\node_modules\electron-prebuilt\dist\resources\electron.asar\renderer\api\remote.js:113:18)

@Qquanwei

This comment has been minimized.

Show comment
Hide comment
@Qquanwei

Qquanwei Nov 23, 2016

this problem occur for me ,

my preload.js

window.pkg = require('electron').remote.require('./package.json');

throw the same error when I access window.pkg


I'm using Lazy load can avoid this bug

window.getPkg = (function(){
  let cache = null;
  return function(){
      if(!cache) cache = require('electron').remote.require('./package.json');
      return cache;
  }
})()

I think load remote object can be safe after window load

Qquanwei commented Nov 23, 2016

this problem occur for me ,

my preload.js

window.pkg = require('electron').remote.require('./package.json');

throw the same error when I access window.pkg


I'm using Lazy load can avoid this bug

window.getPkg = (function(){
  let cache = null;
  return function(){
      if(!cache) cache = require('electron').remote.require('./package.json');
      return cache;
  }
})()

I think load remote object can be safe after window load

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 23, 2016

I'm using require js in a file like this one and keep a reference to remote objects but after few minutes the objects are not accessible anymore

define([
    'moment',
    'async',
    'src/constants'
], function(moment,async, Constants) {
    return {
        remote: require('electron').remote,
        path: require('path'),
        filesys: require('fs'),
        app: require('electron').remote.app,

        init: function() {
            return this;
        },
     
        thumbs: function() {
            var self = this;
            console.log(self.app.getPath('userData'));
        }
    }
});

In few minutes then function thumbs is called 'self.app.getPath' with throw an error

paul321 commented Nov 23, 2016

I'm using require js in a file like this one and keep a reference to remote objects but after few minutes the objects are not accessible anymore

define([
    'moment',
    'async',
    'src/constants'
], function(moment,async, Constants) {
    return {
        remote: require('electron').remote,
        path: require('path'),
        filesys: require('fs'),
        app: require('electron').remote.app,

        init: function() {
            return this;
        },
     
        thumbs: function() {
            var self = this;
            console.log(self.app.getPath('userData'));
        }
    }
});

In few minutes then function thumbs is called 'self.app.getPath' with throw an error

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Nov 25, 2016

Even if i make the remote variables scope vars in thumbs function it's still crashing on CTRL + R or CMD+R

paul321 commented Nov 25, 2016

Even if i make the remote variables scope vars in thumbs function it's still crashing on CTRL + R or CMD+R

@gewl

This comment has been minimized.

Show comment
Hide comment
@gewl

gewl Nov 25, 2016

I've been getting what is (I believe) a related error. I'm using chentsulin's electron-react-boilerplate. Production and dev both work fine, but when I run a test I get this error from electron-json-storage:

[dirpath]/node_modules/electron-json-storage/lib/utils.js:30
const app = electron.app || electron.remote.app;
^

TypeError: Cannot read property 'app' of undefined

Would love any advice on how to fix this!

gewl commented Nov 25, 2016

I've been getting what is (I believe) a related error. I'm using chentsulin's electron-react-boilerplate. Production and dev both work fine, but when I run a test I get this error from electron-json-storage:

[dirpath]/node_modules/electron-json-storage/lib/utils.js:30
const app = electron.app || electron.remote.app;
^

TypeError: Cannot read property 'app' of undefined

Would love any advice on how to fix this!

@MarshallOfSound

This comment has been minimized.

Show comment
Hide comment
@MarshallOfSound

MarshallOfSound Nov 25, 2016

Member

@gewl That's a different error. Looks like either your using tmux or your node_modules install is a bit messed up.

Member

MarshallOfSound commented Nov 25, 2016

@gewl That's a different error. Looks like either your using tmux or your node_modules install is a bit messed up.

@gewl

This comment has been minimized.

Show comment
Hide comment
@gewl

gewl Nov 26, 2016

Not using tmux! node_modules install may be messed up, but if so, this is the only place that it's creating any problems.

I got it worked out. For future reference, (one possible) answer was to use electron-mocha instead of mocha in the test script. Thanks for the suggestions!

gewl commented Nov 26, 2016

Not using tmux! node_modules install may be messed up, but if so, this is the only place that it's creating any problems.

I got it worked out. For future reference, (one possible) answer was to use electron-mocha instead of mocha in the test script. Thanks for the suggestions!

@etyp

This comment has been minimized.

Show comment
Hide comment
@etyp

etyp Nov 28, 2016

@kevinsawicki Please let us know if there's any specific information we can provide to help resolve this issue.

I'm only seeing it on our Windows build now, but previously saw a lot of it on our users with OSX builds:

  • Electron versions: 1.4.1 and 1.3.9
  • OS: Windows 10

Error + stack:

Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object> Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying er 
Stack: 
Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object>
Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object>
    at callFunction (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\browser\rpc-server.js:226:11)
    at EventEmitter.<anonymous> (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\browser\rpc-server.js:307:5)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\browser\api\web-contents.js:219:13)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
    at metaToValue (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\renderer\api\remote.js:210:13)
    at remoteMemberFunction (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\renderer\api\remote.js:111:18)

I can also include our preload.js and usage of require if that helps.

etyp commented Nov 28, 2016

@kevinsawicki Please let us know if there's any specific information we can provide to help resolve this issue.

I'm only seeing it on our Windows build now, but previously saw a lot of it on our users with OSX builds:

  • Electron versions: 1.4.1 and 1.3.9
  • OS: Windows 10

Error + stack:

Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object> Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying er 
Stack: 
Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object>
Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object>
    at callFunction (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\browser\rpc-server.js:226:11)
    at EventEmitter.<anonymous> (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\browser\rpc-server.js:307:5)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\browser\api\web-contents.js:219:13)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
    at metaToValue (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\renderer\api\remote.js:210:13)
    at remoteMemberFunction (C:\Users\Redacted\AppData\Local\Hive\app-1.2.2\resources\electron.asar\renderer\api\remote.js:111:18)

I can also include our preload.js and usage of require if that helps.

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Nov 28, 2016

Contributor

@etyp that stack you posted is a different error, not related to this issue.

Error processing argument at index 0, conversion failure from #<Object>

It looks like setOverlayIcon was called with a first argument of something other than a NativeImage instance.

Contributor

kevinsawicki commented Nov 28, 2016

@etyp that stack you posted is a different error, not related to this issue.

Error processing argument at index 0, conversion failure from #<Object>

It looks like setOverlayIcon was called with a first argument of something other than a NativeImage instance.

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Dec 7, 2016

Contributor

Electron 1.4.11 and 1.3.13 are now out with a potential fix for this issue via #8110.

Can people try updating to those versions and see if they can still reproduce this issue? Thanks.

Contributor

kevinsawicki commented Dec 7, 2016

Electron 1.4.11 and 1.3.13 are now out with a potential fix for this issue via #8110.

Can people try updating to those versions and see if they can still reproduce this issue? Thanks.

@Mic75

This comment has been minimized.

Show comment
Hide comment
@Mic75

Mic75 Dec 7, 2016

On the project I am working on, we had the exception thrown from remote.js while refreshing the app (we were on 1.4.5 and we had to downgrade to 1.3.3).

After upgrading to 1.4.11, no more exception thrown from remote.js, it looks like the issue is fixed !
Thank you sir !

Mic75 commented Dec 7, 2016

On the project I am working on, we had the exception thrown from remote.js while refreshing the app (we were on 1.4.5 and we had to downgrade to 1.3.3).

After upgrading to 1.4.11, no more exception thrown from remote.js, it looks like the issue is fixed !
Thank you sir !

@vintproykt

This comment has been minimized.

Show comment
Hide comment
@vintproykt

vintproykt Dec 7, 2016

@kevinsawicki This fixed my issue with disappearing remote objects. An interesting coincidence is that I have downloaded 1.4.10 three hours ago and got stuck with this problem. Now I'm all set, thank you! 👍

vintproykt commented Dec 7, 2016

@kevinsawicki This fixed my issue with disappearing remote objects. An interesting coincidence is that I have downloaded 1.4.10 three hours ago and got stuck with this problem. Now I'm all set, thank you! 👍

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Dec 8, 2016

Contributor

@paul321 are you able to give the latest releases, 1.3.13 or 1.4.11, a try and see if you still experience this issue? Thanks.

Contributor

kevinsawicki commented Dec 8, 2016

@paul321 are you able to give the latest releases, 1.3.13 or 1.4.11, a try and see if you still experience this issue? Thanks.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Dec 8, 2016

paul321 commented Dec 8, 2016

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Dec 8, 2016

Contributor

I did try it today and it seems fixed :)

Thanks for confirming, will tentatively close this out, it if starts cropping up again we can reopen.

Contributor

kevinsawicki commented Dec 8, 2016

I did try it today and it seems fixed :)

Thanks for confirming, will tentatively close this out, it if starts cropping up again we can reopen.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Dec 12, 2016

I keep getting this error when i reload the application without restart

remote.js:217 Uncaught Error: Cannot call function 'isVisible' on missing remote object 15
Error: Cannot call function 'isVisible' on missing remote object 15
at throwRPCError (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:143:17)
at EventEmitter. (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)

From this piece of code:

var win = require('electron').remote.getCurrentWindow(); if(!win.isVisible()) { win.show(); }

paul321 commented Dec 12, 2016

I keep getting this error when i reload the application without restart

remote.js:217 Uncaught Error: Cannot call function 'isVisible' on missing remote object 15
Error: Cannot call function 'isVisible' on missing remote object 15
at throwRPCError (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:143:17)
at EventEmitter. (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:339:7)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (/Users/Paul/Work/js/desktop/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:231:13)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)

From this piece of code:

var win = require('electron').remote.getCurrentWindow(); if(!win.isVisible()) { win.show(); }

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Dec 12, 2016

Ok my mistake, i didn't updated Electron on this machine :)

paul321 commented Dec 12, 2016

Ok my mistake, i didn't updated Electron on this machine :)

@etyp

This comment has been minimized.

Show comment
Hide comment
@etyp

etyp Jan 26, 2017

Updated to Electron 1.4.14 about 2 weeks ago and our users are still seeing this issue @kevinsawicki . See the screenshot below that shows the stack + the Electron version:

missing-remote-screen

Any idea how we can resolve in the short term? Also, is there any chance that something in their user data folder from an earlier, broken version is causing this to happen despite autoupdate moving them to a new version of Electron?

(Note: this happens with "platform" and "dock" for us)

etyp commented Jan 26, 2017

Updated to Electron 1.4.14 about 2 weeks ago and our users are still seeing this issue @kevinsawicki . See the screenshot below that shows the stack + the Electron version:

missing-remote-screen

Any idea how we can resolve in the short term? Also, is there any chance that something in their user data folder from an earlier, broken version is causing this to happen despite autoupdate moving them to a new version of Electron?

(Note: this happens with "platform" and "dock" for us)

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Jan 31, 2017

Contributor

Any idea how we can resolve in the short term?

Can you include the code running when the error is thrown?

Also, is there any chance that something in their user data folder from an earlier, broken version is causing this to happen despite autoupdate moving them to a new version of Electron?

No, if the console reports 1.4.14 then the update to that version has occurred.

Contributor

kevinsawicki commented Jan 31, 2017

Any idea how we can resolve in the short term?

Can you include the code running when the error is thrown?

Also, is there any chance that something in their user data folder from an earlier, broken version is causing this to happen despite autoupdate moving them to a new version of Electron?

No, if the console reports 1.4.14 then the update to that version has occurred.

@etyp

This comment has been minimized.

Show comment
Hide comment
@etyp

etyp Feb 28, 2017

Sorry for the delay @kevinsawicki

On BrowserWindow instance, we use the webPreferences.preload option like so to avoid conflicting require statements:

// Main Process - main.js

mainWindow = new BrowserWindow({
    webPreferences: {
      nodeIntegration: false,
      preload: path.join(__dirname, 'preload.js')
    }
});

Where preload.js is:

// preload.js

// Use new namespace for require so that
// other modules can use 'require' properly.
DesktopRequire = require;
delete require;

And then on the renderer process (our web app), we define a Desktop object which hold references to select Electron modules like remote:

  // /some/fake/path/desktop.js

  const isDesktop = /Electron/.test(navigator.userAgent) && typeof DesktopRequire !== 'undefined';
  export const Desktop = isDesktop ? {} : false;
  if (typeof DesktopRequire === 'undefined') {
    DesktopRequire = function () { return function () { return false; }; };
  }
  // Keep a reference on the window
  // [Attempt to avoid https://github.com/electron/electron/issues/7351]
  window.Desktop = Desktop;
  window.electron = {};

  $(document).ready(() => {
    window.electron = DesktopRequire('electron');
    // ipc for talking to electron
    Desktop.ipc = electron.ipcRenderer;
    // Catch autoupdate errors
    Desktop.ipc.on('autoUpdaterError', (error, message) => {
      console.log(error);
      console.log(message);
    });
    // remote for calling remote methods
    Desktop.remote = electron.remote;
    // Native Image
    Desktop.nativeImage = electron.nativeImage;
    const appVersion = Desktop.remote.app.getVersion();
    const intAppVersion = parseInt(appVersion.replace(/\./g, ''), 10);
    // Dialog file system
    Desktop.dialog = electron.remote.dialog;
    // New browser windows
    Desktop.window = electron.remote.getCurrentWindow();
  });

Finally, we have an interval that calls this function with a certain number value to update the badge:

// /some/fake/path/set-badge.js
import { Desktop } from '/some/fake/path/desktop.js';
export const setBadge = (text) => {
  const app = window.Desktop.remote.app || Desktop.remote.app;
  const remote = window.Desktop.remote || Desktop.remote;
  const nativeImage = remote.require('electron').nativeImage;

  if (remote.process.platform === 'darwin') {
    app.dock.setBadge('' + text);
  } else if (remote.process.platform === 'win32') {
    const win = remote.getCurrentWindow();

    if (text === '') {
      win.setOverlayIcon(null, '');
      return;
    }

    // Create badge
    const canvas = document.createElement('canvas');
    canvas.height = 140;
    canvas.width = 140;
    const ctx = canvas.getContext('2d');
    ctx.fillStyle = 'red';
    ctx.beginPath();
    ctx.ellipse(70, 70, 70, 70, 0, 0, 2 * Math.PI);
    ctx.fill();
    ctx.textAlign = 'center';
    ctx.fillStyle = 'white';

    if (text.length > 2) {
      ctx.font = '75px sans-serif';
      ctx.fillText('' + text, 70, 98);
    } else if (text.length > 1) {
      ctx.font = '100px sans-serif';
      ctx.fillText('' + text, 70, 105);
    } else {
      ctx.font = '125px sans-serif';
      ctx.fillText('' + text, 70, 112);
    }

    const badgeDataURL = canvas.toDataURL();
    const img = nativeImage.createFromDataURL(badgeDataURL);

    win.setOverlayIcon(img, text);
  }
};

We used to not save the object to the window, but I added this in an attempt to keep remote from being dereferenced. I have a difficult time recreating locally, but we have dozens of users reporting it still happening, plus I see it from time to time.

I'm going to try saving the Desktop object to global scope by not declaring const | let | var before it, but aside from that I'm unsure what to try.

Any help would be absolutely amazing and much appreciated.

etyp commented Feb 28, 2017

Sorry for the delay @kevinsawicki

On BrowserWindow instance, we use the webPreferences.preload option like so to avoid conflicting require statements:

// Main Process - main.js

mainWindow = new BrowserWindow({
    webPreferences: {
      nodeIntegration: false,
      preload: path.join(__dirname, 'preload.js')
    }
});

Where preload.js is:

// preload.js

// Use new namespace for require so that
// other modules can use 'require' properly.
DesktopRequire = require;
delete require;

And then on the renderer process (our web app), we define a Desktop object which hold references to select Electron modules like remote:

  // /some/fake/path/desktop.js

  const isDesktop = /Electron/.test(navigator.userAgent) && typeof DesktopRequire !== 'undefined';
  export const Desktop = isDesktop ? {} : false;
  if (typeof DesktopRequire === 'undefined') {
    DesktopRequire = function () { return function () { return false; }; };
  }
  // Keep a reference on the window
  // [Attempt to avoid https://github.com/electron/electron/issues/7351]
  window.Desktop = Desktop;
  window.electron = {};

  $(document).ready(() => {
    window.electron = DesktopRequire('electron');
    // ipc for talking to electron
    Desktop.ipc = electron.ipcRenderer;
    // Catch autoupdate errors
    Desktop.ipc.on('autoUpdaterError', (error, message) => {
      console.log(error);
      console.log(message);
    });
    // remote for calling remote methods
    Desktop.remote = electron.remote;
    // Native Image
    Desktop.nativeImage = electron.nativeImage;
    const appVersion = Desktop.remote.app.getVersion();
    const intAppVersion = parseInt(appVersion.replace(/\./g, ''), 10);
    // Dialog file system
    Desktop.dialog = electron.remote.dialog;
    // New browser windows
    Desktop.window = electron.remote.getCurrentWindow();
  });

Finally, we have an interval that calls this function with a certain number value to update the badge:

// /some/fake/path/set-badge.js
import { Desktop } from '/some/fake/path/desktop.js';
export const setBadge = (text) => {
  const app = window.Desktop.remote.app || Desktop.remote.app;
  const remote = window.Desktop.remote || Desktop.remote;
  const nativeImage = remote.require('electron').nativeImage;

  if (remote.process.platform === 'darwin') {
    app.dock.setBadge('' + text);
  } else if (remote.process.platform === 'win32') {
    const win = remote.getCurrentWindow();

    if (text === '') {
      win.setOverlayIcon(null, '');
      return;
    }

    // Create badge
    const canvas = document.createElement('canvas');
    canvas.height = 140;
    canvas.width = 140;
    const ctx = canvas.getContext('2d');
    ctx.fillStyle = 'red';
    ctx.beginPath();
    ctx.ellipse(70, 70, 70, 70, 0, 0, 2 * Math.PI);
    ctx.fill();
    ctx.textAlign = 'center';
    ctx.fillStyle = 'white';

    if (text.length > 2) {
      ctx.font = '75px sans-serif';
      ctx.fillText('' + text, 70, 98);
    } else if (text.length > 1) {
      ctx.font = '100px sans-serif';
      ctx.fillText('' + text, 70, 105);
    } else {
      ctx.font = '125px sans-serif';
      ctx.fillText('' + text, 70, 112);
    }

    const badgeDataURL = canvas.toDataURL();
    const img = nativeImage.createFromDataURL(badgeDataURL);

    win.setOverlayIcon(img, text);
  }
};

We used to not save the object to the window, but I added this in an attempt to keep remote from being dereferenced. I have a difficult time recreating locally, but we have dozens of users reporting it still happening, plus I see it from time to time.

I'm going to try saving the Desktop object to global scope by not declaring const | let | var before it, but aside from that I'm unsure what to try.

Any help would be absolutely amazing and much appreciated.

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Mar 1, 2017

We got the same problem when calling the function that is setting the badge icon from code

Uncaught (in promise) Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 1, conversion failure from 6
Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 1, conversion failure from 6

If we run the function from dev console like this App.setBadge('1') it's working find, called from other functions doesn't work

paul321 commented Mar 1, 2017

We got the same problem when calling the function that is setting the badge icon from code

Uncaught (in promise) Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 1, conversion failure from 6
Error: Could not call remote function 'setOverlayIcon'. Check that the function signature is correct. Underlying error: Error processing argument at index 1, conversion failure from 6

If we run the function from dev console like this App.setBadge('1') it's working find, called from other functions doesn't work

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Mar 1, 2017

i think there is a problem setting the badge and i think someone should create a new ticket, check this out:
http://stackoverflow.com/questions/41416052/nativeimage-not-working-in-setoverlayicon-in-electron

paul321 commented Mar 1, 2017

i think there is a problem setting the badge and i think someone should create a new ticket, check this out:
http://stackoverflow.com/questions/41416052/nativeimage-not-working-in-setoverlayicon-in-electron

@paul321

This comment has been minimized.

Show comment
Hide comment
@paul321

paul321 Mar 1, 2017

@etyp i found the error, if you send the text as an integer it's not working, and you will get that error, because in your win.setOverlayIcon(img, text); the text var could be integer, try to to send text+''

paul321 commented Mar 1, 2017

@etyp i found the error, if you send the text as an integer it's not working, and you will get that error, because in your win.setOverlayIcon(img, text); the text var could be integer, try to to send text+''

@etyp

This comment has been minimized.

Show comment
Hide comment
@etyp

etyp Mar 8, 2017

@paul321 good find, but turns out it's not the issue we're encountering. We convert to string every time, plus we still see the error on Mac AND Windows, despite returning early from that function if on darwin.

Just some of the recent errors thrown:

OSX 10.9.5 sample:

Error: Cannot get property 'dock' on missing remote object 4877

Windows 7 sample:

Error: Cannot get property 'platform' on missing remote object 554

Windows 10 sample:

Error: Cannot get property 'platform' on missing remote object 554

OSX 10.12.13 sample:

Error: Cannot get property 'nativeImage' on missing remote object 343

OSX 10.12.3 sample:

Error: Cannot get property 'dock' on missing remote object 12

OSX 10.12.3 sample:

Error: Cannot get property 'platform' on missing remote object 76

Is anybody else that no longer encounters this using es6 modules?

I know that imports are meant to keep 1 cached version in memory after the first time they're imported, but I'm worried something else is going wrong here (hence the saving references to window.Whatever).

etyp commented Mar 8, 2017

@paul321 good find, but turns out it's not the issue we're encountering. We convert to string every time, plus we still see the error on Mac AND Windows, despite returning early from that function if on darwin.

Just some of the recent errors thrown:

OSX 10.9.5 sample:

Error: Cannot get property 'dock' on missing remote object 4877

Windows 7 sample:

Error: Cannot get property 'platform' on missing remote object 554

Windows 10 sample:

Error: Cannot get property 'platform' on missing remote object 554

OSX 10.12.13 sample:

Error: Cannot get property 'nativeImage' on missing remote object 343

OSX 10.12.3 sample:

Error: Cannot get property 'dock' on missing remote object 12

OSX 10.12.3 sample:

Error: Cannot get property 'platform' on missing remote object 76

Is anybody else that no longer encounters this using es6 modules?

I know that imports are meant to keep 1 cached version in memory after the first time they're imported, but I'm worried something else is going wrong here (hence the saving references to window.Whatever).

@etyp

This comment has been minimized.

Show comment
Hide comment
@etyp

etyp Mar 17, 2017

@kevinsawicki might this have anything to do with deleting the require reference on our preload script like this:

// preload.js

// Use new namespace for require so that
// other modules can use 'require' properly.
DesktopRequire = require;
delete require;

etyp commented Mar 17, 2017

@kevinsawicki might this have anything to do with deleting the require reference on our preload script like this:

// preload.js

// Use new namespace for require so that
// other modules can use 'require' properly.
DesktopRequire = require;
delete require;
@whmountains

This comment has been minimized.

Show comment
Hide comment
@whmountains

whmountains May 2, 2017

I get this error 100% of the time when running this example project: https://github.com/avocode/electron-windows-autoupdate.

Uncaught Error: Could not call remote function 'setFeedURL'. Check that the function signature is correct. Underlying error: Could not get code signature for running application
Error: Could not call remote function 'setFeedURL'. Check that the function signature is correct. Underlying error: Could not get code signature for running application
    at callFunction (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:257:11)
    at EventEmitter.<anonymous> (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:357:5)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:256:37)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
    at callFunction (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:257:11)
    at EventEmitter.<anonymous> (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:357:5)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:256:37)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
    at metaToValue (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:234:13)
    at Object.remoteMemberFunction (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:118:18)
    at file:///Users/mmc/code/electron-windows-autoupdate/index.html:31:15

The dependencies in that project are a bit out of date, but after updating everything I still get the same error. I'm running Mac OS 10.12.4 Sierra, using Node v7.9.0, and installing packages with Yarn 0.22.0.

I get this error 100% of the time when running this example project: https://github.com/avocode/electron-windows-autoupdate.

Uncaught Error: Could not call remote function 'setFeedURL'. Check that the function signature is correct. Underlying error: Could not get code signature for running application
Error: Could not call remote function 'setFeedURL'. Check that the function signature is correct. Underlying error: Could not get code signature for running application
    at callFunction (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:257:11)
    at EventEmitter.<anonymous> (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:357:5)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:256:37)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
    at callFunction (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:257:11)
    at EventEmitter.<anonymous> (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:357:5)
    at emitMany (events.js:127:13)
    at EventEmitter.emit (events.js:201:7)
    at WebContents.<anonymous> (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:256:37)
    at emitTwo (events.js:106:13)
    at WebContents.emit (events.js:191:7)
    at metaToValue (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:234:13)
    at Object.remoteMemberFunction (/Users/mmc/code/electron-windows-autoupdate/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:118:18)
    at file:///Users/mmc/code/electron-windows-autoupdate/index.html:31:15

The dependencies in that project are a bit out of date, but after updating everything I still get the same error. I'm running Mac OS 10.12.4 Sierra, using Node v7.9.0, and installing packages with Yarn 0.22.0.

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki May 2, 2017

Contributor

Could not get code signature for running application

@whmountains Auto updating on macOS requires the application to be signed, that is why you are seeing this error.

Contributor

kevinsawicki commented May 2, 2017

Could not get code signature for running application

@whmountains Auto updating on macOS requires the application to be signed, that is why you are seeing this error.

@whmountains

This comment has been minimized.

Show comment
Hide comment
@whmountains

whmountains May 2, 2017

@kevinsawicki Right, so this is a completely different error. Sorry about that.

I'm not going to delete my comment in case someone else searches that error message and finds this thread like I did.

@kevinsawicki Right, so this is a completely different error. Sorry about that.

I'm not going to delete my comment in case someone else searches that error message and finds this thread like I did.

DinoLeung added a commit to DinoLeung/crypto_bloke that referenced this issue Feb 10, 2018

Accessing data from index renderer process
electron.remote module being a total bitch throwing errors randomly
Reference: electron/electron#8205
Reason being electron/electron#7351
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment