Skip to content

Commit

Permalink
Add setTimeout(0) after closing Realm in Jest test to avoid Node 12 s…
Browse files Browse the repository at this point in the history
…egfault (#4025)
  • Loading branch information
tomduncalf authored Oct 14, 2021
1 parent 8a51d6e commit 7acbac5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ x.x.x Release notes (yyyy-MM-dd)
* Lint react-native templates and ensure they are checked by the CI.
* Updated `README.md` and `building.md` with updated instructions on building from source.
* Changed logo to a 'dark-mode' aware SVG ([#4020](https://github.com/realm/realm-js/pull/4020))
* Added workaround for crash when closing Realm in Jest test on Node 12 ([#4025](https://github.com/realm/realm-js/pull/4025), since v10.8.0)
* <Either mention core version or upgrade>
* <Using Realm Core vX.Y.Z>
* <Upgraded Realm Core from vX.Y.Z to vA.B.C>
Expand Down
6 changes: 6 additions & 0 deletions tests/test-runners/jest/realm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ describe("Realm", function () {

expect(realm.isClosed).toBe(true);
Realm.clearTestState();

// Workaround for segfault issue – Node 12 environment teardown after the end of the test
// seems to happen before the Realm is fully closed, resulting in a segfault. Delaying
// the end of the test until the main thread code has finished running with setTimeout
// avoids this. See: https://github.com/realm/realm-js/pull/4025
await new Promise((resolve) => setTimeout(resolve, 0));
}
});
});

0 comments on commit 7acbac5

Please sign in to comment.