msgpackr 2.0.1 → 2.0.3

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.
@@ -1368,7 +1368,14 @@
1368
1368
  let newSharedData = (packr._prepareStructures || prepareStructures)(structures, packr);
1369
1369
  if (!encodingError) { // TODO: If there is an encoding error, should make the structures as uninitialized so they get rebuilt next time
1370
1370
  if (packr.saveStructures(newSharedData, newSharedData.isCompatible) === false) {
1371
- // get updated structures and try again if the update failed
1371
+ // The save was declined (a concurrent writer updated the shared structures,
1372
+ // or the store transaction did not durably commit). Our in-memory
1373
+ // structures + transition trie may now reference record ids that were
1374
+ // never persisted; re-packing as-is would re-emit the same record pointing
1375
+ // at an unpersisted structure (-> "Record id is not defined" on decode).
1376
+ // Mark structures uninitialized so the re-pack reloads durable structures
1377
+ // via getStructures, rebuilds the transition trie, and re-mints + re-saves.
1378
+ structures.uninitialized = true;
1372
1379
  return packr.pack(value, encodeOptions);
1373
1380
  }
1374
1381
  packr.lastNamedStructuresLength = sharedLength;