Is there any mechanism to allow synchronous communication between two BrowserWindows?


I’m trying to package a legacy app that relies on window.opener, which isn’t fully supported by electron. I’ve tried to shim in the ipc to do something like BrowserWindowOne —> MainProcess —> BrowserWindowTwo, but there is no way for this communication flow to remain synchronous (that I see). When I try to communicate from the main process to the secondary browser window, I’m forced to use webContents.send which is asyc.

I agree ideally it would be rewritten to be async, and I understand the desire to attempt to try and prevent deadlocks… but rewriting the application to be async isn’t an option at this point.

Are there any alternative solutions I should consider? Is there a way to avoid the main process altogether and communicate between the BrowserWindow’s directly?


I suspect you could at the very least do HTTP requests between the two windows directly, yes? And even lower level there’s the Node net library.


Thanks for the response leedohm. Spinning up a local HTTP server to communicate between the two BrowserWindow processes on the same machine feels a bit heavyweight. Can you think of any lighter weight alternative?


I wasn’t thinking of anything like setting up Apache … more something like express. HTTP server processes don’t have to be heavyweight. But if that’s still too heavyweight for you, you can always use the Node net library to just open direct TCP connections and talk back and forth.


I recommend this. It is quite easy.