Use realm in a cli program.
The program does its job and exits.
Node does not exit.
require('realm');
console.log('hello');
It prints hello and hangs.
1.12.0An ugly work-around is to call process.exit().
I can reproduce this locally. git bisect between 1.11.1 and 1.12.0 throws up https://github.com/realm/realm-js/commit/e18f54594fa54aa33b2b81f9471835c980309f21 as the offending commit, which is strange because it's just the 'bump version' commit without any code changes.
During the git bisect, I've run the following to get a clean build each time: git clean -xdf && git submodule update --init --recursive && npm install --build-from-source=realm
Interesting. It must indicate that changes in realm-js-private is the trouble-maker. That means, I have to examine the changes there more closely.
I tried to debug the issue and I suspect the problem is within the AdminRealmListener changes but couldn't narrow down the issue yet.
If this is not quick to solve, I think we can postpone this. It seems a minor annoyance only when using in node.js with a script.
This also prevents jest from exiting after finishing all tests.
Now this is a major annoyance as it prevents us from running tests agains in memory realms (or importing realm at all in our tests).
I created a demo project to demonstrate the issue: https://github.com/stigi/realm-require-issue
Edit: The workaround for jest is, running jest with the --forceExit flag. This triggers process.exit when all tests have been run.
Any news on this one ? I can reproduce the described behavior with realm-js 2.3.1 and my jest tests won't terminate without adding the --forceExit hack.
@stigi Thanks for that. Same here. The issue prevents Jest from exiting.
Jest: This usually means that there are asynchronous operations that weren't stopped in your tests.
Sorry, I haven't had time to prioritize it. In plain node scripts, calling process.exit() is fine but I can see the annoyance when you are testing.
@kneth Thanks for getting back to this issue.
I'm less worried about canceling async operations on my test stores than killing some script that works on production data.
Any update on this issue ?
Building older versions of realm with Node v10 (LTS) crashes, building more recent version succeeds, but includes this bug which makes all realm tests fail (and using --forceExit hack for production code is really not the way to go). This means I am stuck with v8 until this issue is resolved.
@cyrusmg No updates to share - sorry. We are in the process to moving our code to a single repository (#2226) which I hope will help us to isolate the bug.
It looks like the issue has been resolved by a recent larger refactoring. At least, it doesn't happen to be when I use v2.28.0.
Most helpful comment
Any news on this one ? I can reproduce the described behavior with realm-js 2.3.1 and my jest tests won't terminate without adding the --forceExit hack.