From de163021472d67acbc5a52ce66d265abc2403f1b Mon Sep 17 00:00:00 2001 From: Andrew Meyer Date: Wed, 15 Dec 2021 13:51:18 +0100 Subject: [PATCH] Tests failing for Node > 14 `napi_create_reference` returns `napi_invalid_arg` instead of `napi_object_expected`. Extended logic for this case. Also updated `node-addon-api` to `4.2.0` --- CHANGELOG.md | 1 + package-lock.json | 14 +++++++------- package.json | 4 ++-- src/node/node_protected.hpp | 2 +- tests/js/list-tests.js | 4 ++++ 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a092ace60..bd7a8680083 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ x.x.x Release notes (yyyy-MM-dd) * If the option `user` in a sync configuration was not a `Realm.User` object could lead to a crash. ([#1348](https://github.com/realm/realm-js/issues/1348), since v10.0.0) * `@sum` and `@avg` queries on Dictionaries of floats or doubles used too much precision for intermediates, resulting in incorrect rounding. (since v10.3.0-rc.1) * Queries of the form `link.collection.@sum = 0` where `link` is `null` matched when `collection` was a List or Set, but not a Dictionary ([realm/realm-core#5080](https://github.com/realm/realm-core/pull/5080), since v10.5.0) +* Fix Realm for versions of Node greater than 14. ### Compatibility * MongoDB Realm Cloud. diff --git a/package-lock.json b/package-lock.json index fc00d1cd26e..1cc5de638d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "fs-extra": "^4.0.3", "https-proxy-agent": "^2.2.4", "ini": "^1.3.7", - "node-addon-api": "^3.1.0", + "node-addon-api": "4.2.0", "node-fetch": "^2.6.1", "node-machine-id": "^1.1.10", "prebuild-install": "^6.1.1", @@ -9782,9 +9782,9 @@ } }, "node_modules/node-addon-api": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz", - "integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.2.0.tgz", + "integrity": "sha512-eazsqzwG2lskuzBqCGPi7Ac2UgOoMz8JVOXVhTvvPDYhthvNpefx8jWD8Np7Gv+2Sz0FlPWZk0nJV0z598Wn8Q==" }, "node_modules/node-emoji": { "version": "1.10.0", @@ -21500,9 +21500,9 @@ } }, "node-addon-api": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz", - "integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.2.0.tgz", + "integrity": "sha512-eazsqzwG2lskuzBqCGPi7Ac2UgOoMz8JVOXVhTvvPDYhthvNpefx8jWD8Np7Gv+2Sz0FlPWZk0nJV0z598Wn8Q==" }, "node-emoji": { "version": "1.10.0", diff --git a/package.json b/package.json index b59dce077cc..1b55da62717 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "fs-extra": "^4.0.3", "https-proxy-agent": "^2.2.4", "ini": "^1.3.7", - "node-addon-api": "^3.1.0", + "node-addon-api": "4.2.0", "node-fetch": "^2.6.1", "node-machine-id": "^1.1.10", "prebuild-install": "^6.1.1", @@ -160,4 +160,4 @@ 4 ] } -} +} \ No newline at end of file diff --git a/src/node/node_protected.hpp b/src/node/node_protected.hpp index 229583899ee..6f51be3dfaa 100644 --- a/src/node/node_protected.hpp +++ b/src/node/node_protected.hpp @@ -44,7 +44,7 @@ class Protected { , m_isValue(false) { napi_status status = napi_create_reference(env, value, 1, &m_ref); - if (status == napi_object_expected) { + if (status == napi_object_expected || status == napi_invalid_arg) { m_isValue = true; Napi::Object object = Napi::Object::New(m_env); object.Set("value", value); diff --git a/tests/js/list-tests.js b/tests/js/list-tests.js index 3f3103918ef..84196a4de4b 100644 --- a/tests/js/list-tests.js +++ b/tests/js/list-tests.js @@ -31,6 +31,10 @@ const DATE3 = new Date(3); const isNodeProcess = typeof process === "object" && process + "" === "[object process]"; const isElectronProcess = typeof process === "object" && process.versions && process.versions.electron; +global.inspect = function (obj) { + console.log("BREAK: ", obj); +}; + module.exports = { testListConstructor: function () { const realm = new Realm({ schema: [schemas.PersonObject, schemas.PersonList] });