realm-js: Process keep hanging after electron app is closed (Windows)
How frequently does the bug occur?
Always
Description
After closing a realm connection, I expect that realm kills all processes related to Realm, but instead there’s always one process that keeps hanging on Windows. This doesn’t seem happen on MacOS, just Windows.
Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
- First thing you need to setup an electron app, which you can use this template for an easy setup.
- Go to
release/appand runyarn install realm. - Create any Realm App with Sync (flexible) enabled.
- Open the realm connection in the main process of Electron.
- Close the realm connection before exiting the app.
- Check task manager for hanging process.
Example code:
...
const app = RealmApp({ id: 'MY_REALM_ID' });
const openRealm = async () => {
// run realm login
const realm = await Realm.open({
schema: [MySchema],
sync: {
user: app.currentUser,
flexible: true,
}
});
realm.close();
}
...
After the above code runs and you close the app, there will be one process from the app still running. If I don’t call the function openRealm, all processes are closed.
I also tested without using sync, and for that everything works fine, so I’m guessing it’s something related to syncSession. Example:
...
const openLocalRealm = async () => {
const realm = await Realm.open({
schema: [MySchema],
});
realm.close();
}
...
This code works as expected, no process hangs after app is closed.
Version
11.7.0
What services are you using?
Atlas Device Sync
Are you using encryption?
Yes
Platform OS and version(s)
Windows 10 Pro 22H2
Build environment
Which debugger for React Native: …
Cocoapods version
No response
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Comments: 26 (14 by maintainers)
With v12.7.0 we have introduced the method Realm.shutdown() to gracefully terminate Realm
@rossicler-hostalky Thank you for sharing the electron issue here, and we will follow it.
I wasn’t before, I did this change according to how it is being done in Realm Studio, but instead of getting an error when trying to install, it seems like it can’t reopen the app after this is called.
I followed the process on my task manager, and I see the installer is running on silent mode, but that process closes and the app doesn’t open, but that process is still running (realm process).
My guess is that the same way it was giving me an error without running install in silent mode, it can’t finish installing because of that process, so it just closes without finishing.
@rossicler-hostalky I’ll bring the issue up at next team meeting
@kneth I see, if there’s anything more I can to help get this sorted faster, please let me know.
@kneth
I did try
pause()before, and it wasn’t enough, but I only tried on v11.7.0.I will take a look at
wtfnodepackage and try to find more information about the process hanging, once I have more insights I will share here.