Add setTimeout(0) after closing Realm in Jest test to avoid Node 12 segfault #4025
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What, How & Why?
Our Jest test started often failing with a segmentation fault on Node 12. This issue started happening after realm/realm-core#4892 was merged. The issue only occurs when
npm install
is run prior tonpm test
and is not 100% consistent, which suggests some kind of race condition.We are assuming that this is a very specific timing issue on Node 12 only, related to the Node environment being torn down before the Realm is properly closed, and unlikely to have any real world impact. Adding a
setTimeout(0)
at the end of the test appears to be enough to delay the Node environment teardown and avoid the segfault.A follow up issue #4026 has been created in case of any further possibly related issues. The referenced doc on that ticket has full notes on the investigation.
☑️ ToDos
Compatibility
label is updated or copied from previous entryBreaking
label has been applied or is not necessaryIf this PR adds or changes public API's:
[ ] typescript definitions file is updated[ ] jsdoc files updated[ ] Chrome debug API is updated if API is available on React Native