In my electron app, I am receiving an error "No handler registered for 'channel-name' at EventEmitter../lib/renderer/api/ipc-renderer.ts.ipcRenderer.invoke (electron/js2c/renderer_init.js:1163:19)". IPC handle is not registered and the communication between renderer and main process is not working as expected in Windows.
When I open the app from windows installer, I see this issue and it's intermittent when open the app from the applications on windows.
Here is the code snippet of how I used ipc handle/invoke.
In Main.ts file
import {ipcMain} from 'electron';
private registerIpcChannels(ipcChannels: IpcChannelInterface[]) {
try {
for(const channel of ipcChannels) {
ipcMain.handle(channel.getName(), async (event, request) => await channel.handleInvoke(event, request))
}
} catch (err) {
log.error(`Unable to register IPC channels: ${err.message}`, err);
}
}
In Renderer.js file:
import electron from 'electron';
sendMessage(msg) {
let ipc = electron.ipcRenderer;
ipc.invoke(channelName, msg);
}
I don't understand that why it is working completely fine in MacOS but not on windows. I followed the documentation to implement handle/invoke in electron app. Environment info: Electron - v8.5.2 Nodejs - v12.16.1 OS - Windows 10
Note: This is happening only at the time of first-time launch. After refresh or quit and reopen the app, it works fine
Can anyone help to figure out why this issue is occurring?