Could not open realm in partial mode



Hey there.

I try to do something basic and very simple - open new realm database with “partial” mode.
I used code from “Get Started” example:

const faker = require('faker');
const Realm = require('realm');
const fs = require('fs');

const totalTickers = 100;
const USERNAME = "test-admin";
const PASSWORD = "123456";
const SERVER = "";

const TickerSchema = {
    name: 'Ticker',
    primaryKey: 'tickerSymbol',
    properties: {
        tickerSymbol: {type: 'string', optional: false},
        price: {type: 'int', optional: false},
        companyName: {type: 'string', optional: false},

const token = "some token";

// Unlock Professional Edition APIs

function generateRandomTickerSymbol(len) {
    let randomString = '';
    for (let i = 0; i < len; i++) {
        let randomPoz = Math.floor(Math.random() * charSet.length);
        randomString += charSet.substring(randomPoz, randomPoz + 1);
    return randomString;

function getStarted() {
    Realm.Sync.User.login(`https://${SERVER}`, USERNAME, PASSWORD)
        .then(user => {
        //    let rdb = new Realm({sync: {user, url: `realms://${SERVER}/global6/tickers`,  fullSynchronization: false}});
                sync: {
                    url: `realms://${SERVER}/global9/tickers`,
                    user: user,
                    fullSynchronization: false
                schema: [TickerSchema],
                .then(realm => {
                    let tickerResults = realm.objects('Ticker');
                    // Add some data to the tickers Realms
                    if (tickerResults.length < totalTickers) {
                        realm.write(() => {
                            for (let index = 0; index < totalTickers; index++) {
                                realm.create('Ticker', {
                                    tickerSymbol: generateRandomTickerSymbol(3),
                                    price: index,
                                }, true)


I just added: fullSynchronization: false in the sync section.
And on run - I got error:

node client.js
Realm.Sync.setFeatureToken() is deprecated and you can remove any calls to it.
logged in as 27da39ae0d716adfdd9849246c7c2db8 isAdmin true
Error: Unable to open a realm at path 'C:\Users\yatree\WebstormProjects\rcload2\realm-object-server\da472290-da1d-4c23-996f-7274a63a7578\realms%3A': make_dir() failed: No such file or directory.
    at Realm.Sync.User.login.then.user (C:\Users\yatre\WebstormProjects\rcload2\client.js:108:17)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

I run the script on Windows 10
NodeJS: v8.4.0
realm-js: 2.14.0 (got it from changelog file)

If I will change fullSync option to true - the script will work, on Realm Cloud realm will be created.
Did I miss something?


Looks like the problem is that the generated path is too long for Windows. Can you try to run the script from C:\t or a similar folder with a short path?


No. This does not help, but I solved it in another way :slight_smile: Switched to Linux.

I don’t want to create another’s topics, so will ask here several other questions.

This code is from realm docs:

// Example of restricting the object to the user creating it.
let user = Realm.Sync.User.current;

// Permissions must be modified inside a write transaction
realm.write(() => {
    // Create role unique to user
    let role = realm.create('__Role', { name: user.identity });
    // Create a new permission object for the role
    // and add it to the objects permissions
    let permission = realm.create('__Permission', { role: role });
    ['canRead', 'canUpdate', 'canDelete', 'canSetPermissions', 'canQuery', 'canCreate', 'canModifySchema'].forEach((p) => permission[p] = true);
    let objectPermissions = realm.objects('__Class').filtered(`class_name = 'Person'`)[0];

First of all - these objects: __Permission, __Class, _Rose, __Users were not in realm schema - I had added them, because of errors like this:

 Unhandled promise rejection (rejection id: 1): Error: Object type '__Class' not found in schema.

With Class object I have another problem:

(node:28153) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: The following changes cannot be made in additive-only schema mode:
- Primary Key for class '__Class' has changed from 'name' to 'class_name'.

I just used example script and code from the documentation. What is wrong?

And last problem:

Connection[1]: Connection closed due to error
Connection[1]: Connected to endpoint '' (from '')
ERROR: Connection[1]: Websocket: Expected HTTP response 101 Switching Protocols, but received:
HTTP/1.1 502 Bad Gateway
Connection: keep-alive
Content-Length: 173
Content-Type: text/html
Date: Thu, 26 Jul 2018 19:27:29 GMT
Server: nginx/1.13.5

<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>

This appears now always and when I just started testings - everything was fine. What does it mean?


That error is saying that you changed the schema definition for __Class from ‘name’ to ‘class_name’, how did you add those Object types to your schema the first time? Manually I’d guess

The correct way to add them would be using the predefined object types, like so…

let schema = [

As for the error, you are making a destructive change which isn’t allowed. If you are in development just create a new realm and abandon the old one, in production you’d need to migrate.

The 502 errors have been happening quite allot in the past few days, not sure why, you’d need to open a ticket.


I added them like this (as you already wrote):

let schema = [

If I add Realm.Permissions.Class - I got the error about changes in the schema, if not - I got the error about __Class is not presented in realm schema.

Then I tried to create a new realm with the same configuration (before I just “opened” it), and I get this error message:

Failed to transform received changeset: Schema mismatch: '__Class' has primary key 'name' on one side, but primary key 'class_name' on the other

I did not change the code in the realm library, and for sure I can not change the schema on the cloud side. :slight_smile: