SharedObject goes RangeError: Error #2006

If you keep getting RangeError: Error #2006: The supplied index is out of bounds. with SharedObject, you probably not gonna fix it. In my case this happend when I tried to write non primitive values too frequently into persistant SharedObject’s properties. After reconnect, before any event from your SharedObject dispatched, you get exception that will cause browser crash.

I was not able to solve it by excluding saving advanced objects, nor by using just simple Objects, AMF0 or AMF3, nor by any other method I imagined. To solve the problem I decided to write only serialized objects (strings) and deserialize again on client after synchronization.