@colyseus/schema 2.0.19 → 2.0.20

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.
@@ -2171,7 +2171,16 @@ class ReferenceTracker {
2171
2171
  }
2172
2172
  // for decoding
2173
2173
  removeRef(refId) {
2174
- this.refCounts[refId] = this.refCounts[refId] - 1;
2174
+ const refCount = this.refCounts[refId];
2175
+ if (refCount === undefined) {
2176
+ console.warn(`trying to remove reference ${refId} that doesn't exist`);
2177
+ return;
2178
+ }
2179
+ if (refCount === 0) {
2180
+ console.warn(`trying to remove reference ${refId} with 0 refCount`);
2181
+ return;
2182
+ }
2183
+ this.refCounts[refId] = refCount - 1;
2175
2184
  this.deletedRefs.add(refId);
2176
2185
  }
2177
2186
  clearRefs() {