1

I'm trying to implement in my electron application.

In main.ts :

  ipcMain.handle('some-name', async (event, someArgument) => {
    console.log("--------------------")
    console.log(someArgument)
    console.log("--------------------")
    return true
  })

In a React.Component, I got :

import { ipcRenderer } from 'electron'
...
ipcRenderer.invoke('some-name',"sadkjasd").then((result) => {
      console.log("finished")
    })

And it's giving me error, saying :

Uncaught (in promise) Error: Error invoking remote method 'some-name': No handler registered for 'some-name'
    at EventEmitter.o.invoke (electron/js2c/renderer_init.js:71)

How can I register an event ?

I'm actually trying to figure out IPC of GitHub desktop, that's one cool electron app :

Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86
  • You could try using `on` and `send` in electron by referring to this answer https://stackoverflow.com/a/67436511/14176786 – Atheesh Thirumalairajan May 09 '21 at 02:23
  • I am not sure if you would use `on` or `send` or instead you only want to use `invoke` – Atheesh Thirumalairajan May 09 '21 at 02:24
  • 2
    `send` and `on` pair didn't worked... it didn't triggered... that's why i was foing through doc again and found this code : `invoke` and `handle` pair... it raised error.. now i'm all confused.. – Maifee Ul Asad May 09 '21 at 10:44
  • I had that kind of error message too `Error occurred in handler for 'channelName': No handler registered for 'channelName'` what worked in my case was to close the app and start it again. You may also want to take a look at the [Inter-Process Communications guide](https://www.electronjs.org/docs/latest/tutorial/ipc) from the doc – Darkosphere Dec 06 '22 at 13:29

0 Answers0