You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using map schema to track last 5 games in state. For first 5 games it works fine as last 5 game map is empty but after sixth game when i remove a value and add new value in state it gives error
index.js:2313 Uncaught TypeError: Cannot read properties of undefined (reading '$changes')
at eval (index.js:2313:41)
at Set.forEach ()
at ReferenceTracker.garbageCollectDeletedRefs (index.js:2292:30)
at Schema.decode (index.js:2679:19)
at SchemaSerializer.patch (SchemaSerializer.js:13:27)
at Room.patch (Room.js:220:25)
at Room.onMessageCallback (Room.js:195:18)
So i tried some changes to file ./node_module/@colyseus/schema/build/umd/index.js
add if(ref != undefined) solved the issue in else condition
// for decodingReferenceTracker.prototype.garbageCollectDeletedRefs=function(){var_this=this;this.deletedRefs.forEach(function(refId){//// Skip active references.//if(_this.refCounts[refId]>0){return;}varref=_this.refs.get(refId);//// Ensure child schema instances have their references removed as well.//if(refinstanceofSchema){for(varfieldNameinref['_definition'].schema){if(typeof(ref['_definition'].schema[fieldName])!=="string"&&ref[fieldName]&&ref[fieldName]['$changes']){_this.removeRef(ref[fieldName]['$changes'].refId);}}}elseif(ref!=undefined){vardefinition=ref['$changes'].parent._definition;vartype=definition.schema[definition.fieldsByIndex[ref['$changes'].parentIndex]];if(typeof(Object.values(type)[0])==="function"){Array.from(ref.values()).forEach(function(child){return_this.removeRef(child['$changes'].refId);});}}_this.refs.delete(refId);delete_this.refCounts[refId];});// clear deleted refs.this.deletedRefs.clear();};returnReferenceTracker;
Context
Front end JS SDK
Bug description
Using map schema to track last 5 games in state. For first 5 games it works fine as last 5 game map is empty but after sixth game when i remove a value and add new value in state it gives error
index.js:2313 Uncaught TypeError: Cannot read properties of undefined (reading '$changes')
at eval (index.js:2313:41)
at Set.forEach ()
at ReferenceTracker.garbageCollectDeletedRefs (index.js:2292:30)
at Schema.decode (index.js:2679:19)
at SchemaSerializer.patch (SchemaSerializer.js:13:27)
at Room.patch (Room.js:220:25)
at Room.onMessageCallback (Room.js:195:18)
Steps to reproduce
Login at http://3.28.126.178/
U-MA0001
P-1234
go to Manage games and view games
wait for sometime it will start showing this
Environment & Versions
"colyseus": "^0.15.9",
Node - v20.10.0
TypeScript - 4.9.5
OS -Ubuntu- v20
The text was updated successfully, but these errors were encountered: