deepstream.io: Invalid state transition. Details: {"transition":"MERGED","state":"READY"}

I’ve faced with the following error for some records during trying to update record:

Invalid state transition.
Details: {"transition":"MERGED","state":"READY"} 
History: 
	From - to LOADING_OFFLINE via -
	From LOADING_OFFLINE to SUBSCRIBING via 23
	From SUBSCRIBING to READY via 4

StateMachine.transition             @ state-machine.ts:37
RecordCore.onRecordRecovered        @ record-core.ts:767
eval                                @ merge-strategy-service.ts:75
exports.REMOTE_WINS                 @ merge-strategy.ts:8
MergeStrategyService.merge          @ merge-strategy-service.ts:74
RecordCore.recoverRecordFromMessage @ record-core.ts:726
RecordCore.RecordHandler            @ record-core.ts:480
RecordHandler.handle                @ record-handler.ts:411
eval                                @ connection.ts:323
Connection.onMessages               @ connection.ts:297
socket.onmessage                    @ socket-factory.ts:42

Code is simple:

const { DeepstreamClient } = window.DeepstreamClient;
const client = new DeepstreamClient(url, { path: '' } );

client.login((success) => {
  if (success) {
    client.record.getRecord('user').whenReady((record) => {
      record.set('test', 1);
    });
  }
});

There are many following messages in pm2 error logs:

VERSION_EXISTS | open tried to update record user to version 19633 but it already was 19632

Server version: 5.1.1 Client version: 5.1.4

What is the reason for the error? How can the error be fixed?

Thank you

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 30 (10 by maintainers)

Most upvoted comments

I’ve been able to reproduce the issue by following steps.

  1. Code with updating record by interval
var recordName = 'test';
const { DeepstreamClient } = window.DeepstreamClient;
client = new DeepstreamClient(serverUrl, { path: '' } );

client.login({}, function () {
    var currentUserRecord = client.record.getRecord(recordName);
    currentUserRecord.whenReady(function (record) {
        var updateRecord = function() {
            var currentdate = new Date();
            var datetime = currentdate.getMinutes() + ":" + currentdate.getSeconds();
            record.set('time', currentdate, err => {
                if (err) {
                    console.log('Record set with error:', err)
                } else {
                    console.log('Record set without error')
                }
            });
        }
        var updateRecordInterval = setInterval(updateRecord, 1000);
    });
});
  1. Disconnect the connection (disable internet, etc.)
  2. Then I get the error in the console and cannot update the record anymore

I think this case should be handled by Deepstream Client

i’ll take a look at this this weekend, seems quite a few people are running into it

thank you for the code! yeah that should be covered.

I’m currently a bit busy on another deadline, but will pick this up as soon as I have time.

Closing this for now. Please re-open if issue persists.