msgpackr 1.11.13 → 1.11.14

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.
package/dist/node.cjs CHANGED
@@ -1428,7 +1428,14 @@ class Packr extends Unpackr {
1428
1428
  let newSharedData = prepareStructures$1(structures, packr);
1429
1429
  if (!encodingError) { // TODO: If there is an encoding error, should make the structures as uninitialized so they get rebuilt next time
1430
1430
  if (packr.saveStructures(newSharedData, newSharedData.isCompatible) === false) {
1431
- // get updated structures and try again if the update failed
1431
+ // The save was declined (a concurrent writer updated the shared structures,
1432
+ // or the store transaction did not durably commit). Our in-memory
1433
+ // structures + transition trie may now reference record ids that were
1434
+ // never persisted; re-packing as-is would re-emit the same record pointing
1435
+ // at an unpersisted structure (-> "Record id is not defined" on decode).
1436
+ // Mark structures uninitialized so the re-pack reloads durable structures
1437
+ // via getStructures, rebuilds the transition trie, and re-mints + re-saves.
1438
+ structures.uninitialized = true;
1432
1439
  return packr.pack(value, encodeOptions)
1433
1440
  }
1434
1441
  packr.lastNamedStructuresLength = sharedLength;