Assertion Failed: Both operations have to have the same base length
Version info
Firebase:8.81
@hackerrank/firepad: 0.3.1
@monaco-editor/react: 4.3.1
Replication Steps: None, i have tried to reproduce this while collaborating linux with linux, linux with mac, mac with mac, mac with windows, windows with windows and windows with linux.
This happens intermittently to our prod users and i haven't been able to reproduce this, i was previously using firepad and had the same issue so thought of using firepad-x hoping this would have solved the problem. This error is always in conjuction with 2-3 more errors as follows:-
The base length of the second operation has to be the target length of the first operation , Invalid Operation Encountered: sendOperation() called with invalid operation.
This was first reproduced by me but then i read one our your posts and set EOL preference to be same for all the users and haven't been able to reproduce it since but still this error pops up in our prod environment intermittently and breaks collaboration.
Can you guide me around what could be causing this problem and what could be a possible solution to fix this.
Can you share firebase data from the session where this error occurred? The firebase data will contain all the TextOperations recorded for the session, so you'll able to construct the final document by combining all the TextOperations.
Every TextOperation instance has _baseLength which is the size of the document on which the TextOperation can be applied and _targetLength which is the size of resulting document.
To put it simply, suppose there's two TextOperations A, and B. Note: This is a simplified example, and actual structure of TextOperaton is different.
A = { _baseLength: 10, _targetLength: 14, op: "Adit" } and B = { _baseLength: 14, _targetLength: 16, op: "ya" }. Then A.compose(B) will be { _baseLength: 10, _targetLength: 16, op: "Aditya" }.
From what you wrote, it seems that the error happens in the following places:
- In compose function: https://github.com/interviewstreet/firepad-x/blob/4c94ce5c31f4387609c0b3b83d46c7a86c907d36/src/text-operation.ts#L419-L422
- In sendOperation function: https://github.com/interviewstreet/firepad-x/blob/4c94ce5c31f4387609c0b3b83d46c7a86c907d36/src/firebase-adapter.ts#L437-L444
By the firebase data, we can try to manually compose all TextOperation to find the offending one (Point 1).
Also, as you can see from point 2, we emit FirebaseAdapterEvent.Error when sendOperation fails. This contains the offending TextOperation, and the document. Can you add logging in your application to track FirebaseAdapterEvent.Error, and then report it here when it happens again?