@colyseus/schema 3.0.50 → 3.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1586,7 +1586,12 @@ const encodeArray = function (encoder, bytes, changeTree, field, operation, it,
1586
1586
  const useOperationByRefId = hasView && changeTree.isFiltered && (typeof (changeTree.getType(field)) !== "string");
1587
1587
  let refOrIndex;
1588
1588
  if (useOperationByRefId) {
1589
- refOrIndex = ref['tmpItems'][field][$changes].refId;
1589
+ const item = ref['tmpItems'][field];
1590
+ // Skip encoding if item is undefined (e.g. when clear() is called)
1591
+ if (!item) {
1592
+ return;
1593
+ }
1594
+ refOrIndex = item[$changes].refId;
1590
1595
  if (operation === OPERATION.DELETE) {
1591
1596
  operation = OPERATION.DELETE_BY_REFID;
1592
1597
  }