realm-js
realm-js copied to clipboard
TypeError: externalRealm.syncSession.uploadAllLocalChanges is not a function
Goals
I am trying to await the uploading of all changes
Expected Results
Expected it to upload all of the changes
Actual Results
TypeError: externalRealm.syncSession.uploadAllLocalChanges is not a function
Steps to Reproduce
Open a synced realm, and call realm.syncSession.uploadAllChanges()
Code Sample
externalRealm.syncSession.uploadAllLocalChanges()
Version of Realm and Tooling
- Realm JS SDK Version: 2.29.2
- Node or React Native: v10.16.0
- Client OS & Version: Mac
- Which debugger for React Native: ?/None
As we have a test of uploadAllLocalChanges()
, we need to be able to reproduce it. Moreover, I routinely use the method (and its twin downloadAllServerChanges()
) in small scripts and apps.
We no longer experience this issue, since we modified our jest environment to use jest-environment-node
, so I'll close this.
➤ Unito Sync Bot commented:
Transition made by Unito
We no longer experience this issue, since we modified our jest environment to use
jest-environment-node
, so I'll close this.
We aren't using jest-environment-node
as-is but are instead doing the following in order to use script.runInThisContext()
instead of script.runInContext()
.
// Adapted from https://github.com/facebook/jest/issues/2549#issuecomment-521250266.
//
// Note that this must be a JavaScript module until jest supports transforms on the
// "testEnvironment" configuration option to allow transparently converting it from TypeScript.
// See https://github.com/facebook/jest/issues/8479 for more details.
const NodeEnvironment = require('jest-environment-node');
module.exports = class extends NodeEnvironment {
constructor(config) {
super(config);
this.global = global;
}
runScript(script) {
return script.runInThisContext();
}
};
As I mentioned in my comment in https://github.com/realm/realm-js/issues/1096#issuecomment-542741556, this issue isn't specific to jest and is a problem with how Realm fails to install prototypes correctly when the module is loaded in a separate VM context.