realm-js: node does not exit if realm-js is imported

Goals

Use realm in a cli program.

Expected Results

The program does its job and exits.

Actual Results

Node does not exit.

Steps to Reproduce

  1. Import realm-js

Code Sample

require('realm');
console.log('hello');

It prints hello and hangs.

Version of Realm and Tooling

  • Realm JS SDK Version: the issue first appeared in 1.12.0
  • Node or React Native: Node 6.11.3
  • Client OS & Version: macOS 10.12.6 and Debian 8

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

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.

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.

I tried to debug the issue and I suspect the problem is within the AdminRealmListener changes but couldn’t narrow down the issue yet.

I think we’re also hitting this in Jest.

@kneth can we reopen this since it still appears to be happening? Or would you prefer we raise a new bug for it?

it still happen at versión v10.5.0

Looks like still occurs in 10.4.2

@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.