Skip to content
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

windowManager emit getting error #34

Open
rawatsandeep670 opened this issue Mar 7, 2017 · 2 comments
Open

windowManager emit getting error #34

rawatsandeep670 opened this issue Mar 7, 2017 · 2 comments

Comments

@rawatsandeep670
Copy link

  • Electron version: 1.6.1
  • Operating system: Window 7 - 64bit

Expected behavior

send data one window to another window using windowManager.bridge.emit

Actual behavior

Uncaught Error: Could not call remote function 'emit'. Check that the function signature is correct. Underlying error: Cannot read property 'id' of undefined
Error: Could not call remote function 'emit'. Check that the function signature is correct. Underlying error: Cannot read property 'id' of undefined
at callFunction (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:259:11)
at EventEmitter. (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:366:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:249:37)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
at callFunction (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:259:11)
at EventEmitter. (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:366:5)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents. (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:249:37)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:191:7)
at metaToValue (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:218:13)
at Object.remoteMemberFunction (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:114:18)
at setSmartFoxInstance (http://localhost:9000/scripts/services/deskTileView.js:751:34)
at http://localhost:9000/scripts/services/deskTileView.js:199:33
at CallbacksRegistry.apply (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\common\api\callbacks-registry.js:48:42)
at EventEmitter. (C:\Users\Sandeep\AppData\Roaming\npm\node_modules\electron\dist\resources\electron.asar\renderer\api\remote.js:283:21)
at emitThree (events.js:116:13)
at EventEmitter.emit (events.js:194:7)

How to reproduce

open any window using windowManager e.g.
let myWindow = windowManager.open('home1', "welcom", 'http://localhost:9000/**.html', null, null, true);

after onReady calll
windowManager.bridge.emit('new_chat_message', {});

@jeefuji
Copy link

jeefuji commented Apr 5, 2017

Hello :)
Same error here, but calling from the renderer process.

  • Open a windows
  • Sending an event when window is loaded
  • Getting this error

I guess i'll check the source code to see if there is a bug ?

Edit :
Actually the crash is in the getCurrent() methods, line 976. Seems that BrowserWindow.getFocusedWindow() return something weird. Actually the api check if the focused window is null, so we should have this id.

Weird. Maybe because de BrowserWindow is not fully loaded ?

@0x779
Copy link

0x779 commented Jun 12, 2017

I worked around it by specifying the emmiter:
'emit': function(event, data, target, instigator){ windowManager.eventEmitter.emit(event, { 'emittedBy': instigator, 'target': target, 'data': data }); }

You can then use emit with
windowManager.bridge.emit(event, data, targetWindowName, currentWindowName);

It's hacky, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants