diff --git a/lib/extensions.js b/lib/extensions.js index 256149e7..3bcdb051 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -50,7 +50,8 @@ module.exports = function(realmConstructor) { } let syncedRealm = new realmConstructor(config); - setTimeout(_ => { resolve(syncedRealm); }, 1); //FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented + //FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented + setTimeout(() => { resolve(syncedRealm); }, 1); }); }); }, @@ -62,7 +63,8 @@ module.exports = function(realmConstructor) { } let syncedRealm = new realmConstructor(config); - callback(null, syncedRealm); + //FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented + setTimeout(() => { callback(null, syncedRealm); }, 1); }); }, })); diff --git a/tests/js/session-tests.js b/tests/js/session-tests.js index a72a5316..51ef57e6 100644 --- a/tests/js/session-tests.js +++ b/tests/js/session-tests.js @@ -22,11 +22,24 @@ const Realm = require('realm'); const TestCase = require('./asserts'); -const tmp = require('tmp'); -const fs = require('fs'); -const execFile = require('child_process').execFile; -tmp.setGracefulCleanup(); +const isNodeProccess = (typeof process === 'object' && process + '' === '[object process]'); +console.log("isnode " + isNodeProccess + " typeof " + typeof process === 'object'); +function node_require(module) { + return require(module); +} + +let tmp; +let fs; +let execFile; + +if (isNodeProccess) { + tmp = node_require('tmp'); + fs = node_require('fs'); + execFile = node_require('child_process').execFile; + tmp.setGracefulCleanup(); +} + function uuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { @@ -110,8 +123,6 @@ module.exports = { }, testRealmOpen() { - const isNodeProccess = typeof process === 'object'; - if (!isNodeProccess) { return Promise.resolve(); } @@ -164,8 +175,6 @@ module.exports = { }, testRealmOpenAsync() { - const isNodeProccess = typeof process === 'object'; - if (!isNodeProccess) { return Promise.resolve(); }