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

Multi-threaded support for Electron / NodeJS #6584

Open
bimusiek opened this issue Apr 3, 2024 · 3 comments
Open

Multi-threaded support for Electron / NodeJS #6584

bimusiek opened this issue Apr 3, 2024 · 3 comments

Comments

@bimusiek
Copy link
Contributor

bimusiek commented Apr 3, 2024

Problem

Hey, we are looking into offloading some of the workloads of our app to separate thread in NodeJS (Electron specifically).
I remember there was some example with sync: true config, that utilised separate BrowserWindow, but I cannot remember where it was located.

Electron supports WebWorkers, however it is discouraged to import NativeModules inside the worker due to lack of support from libraries. Do you know if Realm supports multi-threading for NodeJS Workers though?
https://www.electronjs.org/docs/latest/tutorial/multithreading#native-nodejs-modules

I found this issue, so it looks like workers are not yet supported?
Maybe you have workaround for Electron case though? Like spawning 2 browser windows, which would theoretically have 2 separate event loops?

Can it be done? And can both threads use the same Sync configuration and can both write to the Realm? Or one has to be read-only? Or maybe it is not possible at all?

Solution

No response

Alternatives

No response

How important is this improvement for you?

Would be a major improvement

Feature would mainly be used with

Atlas Device Sync

Copy link

sync-by-unito bot commented Apr 3, 2024

➤ PM Bot commented:

Jira ticket: RJS-2787

@kneth
Copy link
Member

kneth commented Apr 5, 2024

@bimusiek It is correct that we don't support web workers or nodejs workers.

We are working on multi-process support for Atlas Device Sync; unfortunately it is too early to give you a release date. The sync: true is currently the best option.

The async transactions as discussed in #1099 might be a future feature to add. Some Atlas Device SDKs have implemented async transactions (for example Realm Swift). I wonder if async transactions will meet your requirements better.

@elle-j
Copy link
Member

elle-j commented Apr 9, 2024

@bimusiek, our current Electron example uses one BrowserWindow.

P.S. that example does not use sync: true (which btw is now moved to an internal config prop openSyncedRealmLocally: true), but opens the Realm as usual.

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

No branches or pull requests

3 participants