@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.
@@ -1588,7 +1588,12 @@ const encodeArray = function (encoder, bytes, changeTree, field, operation, it,
1588
1588
  const useOperationByRefId = hasView && changeTree.isFiltered && (typeof (changeTree.getType(field)) !== "string");
1589
1589
  let refOrIndex;
1590
1590
  if (useOperationByRefId) {
1591
- refOrIndex = ref['tmpItems'][field][$changes].refId;
1591
+ const item = ref['tmpItems'][field];
1592
+ // Skip encoding if item is undefined (e.g. when clear() is called)
1593
+ if (!item) {
1594
+ return;
1595
+ }
1596
+ refOrIndex = item[$changes].refId;
1592
1597
  if (operation === exports.OPERATION.DELETE) {
1593
1598
  operation = exports.OPERATION.DELETE_BY_REFID;
1594
1599
  }