jsonnull/electron-trpc

Add support for different router types

Opened this issue · 0 comments

Hi,

In my application I have two windows with different type of routers. For both windows I'm trying to register IPC handlers using createIPCHandler({router: router1, windows: [win1]}) and createIPCHandler({router: router2, windows: [win2]}).
When I try to invoke some query from win1, I'm getting the following error:

TRPCClientError: No "query"-procedure on path "getSomething"

I assume it happens because both routers replies to the same query simultaneously which brings to race condition. In my case, router2 is trying to handle a query that can be handled only by router1.
It would be nice to check event.source inside ipcMain.on message handler and process only those messages which come from BrowserWindow passed in windows property of createIPCHandler call.