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.
package/pack.js CHANGED
@@ -188,7 +188,14 @@ export class Packr extends Unpackr {
188
188
  let newSharedData = (packr._prepareStructures || prepareStructures)(structures, packr);
189
189
  if (!encodingError) { // TODO: If there is an encoding error, should make the structures as uninitialized so they get rebuilt next time
190
190
  if (packr.saveStructures(newSharedData, newSharedData.isCompatible) === false) {
191
- // get updated structures and try again if the update failed
191
+ // The save was declined (a concurrent writer updated the shared structures,
192
+ // or the store transaction did not durably commit). Our in-memory
193
+ // structures + transition trie may now reference record ids that were
194
+ // never persisted; re-packing as-is would re-emit the same record pointing
195
+ // at an unpersisted structure (-> "Record id is not defined" on decode).
196
+ // Mark structures uninitialized so the re-pack reloads durable structures
197
+ // via getStructures, rebuilds the transition trie, and re-mints + re-saves.
198
+ structures.uninitialized = true;
192
199
  return packr.pack(value, encodeOptions);
193
200
  }
194
201
  packr.lastNamedStructuresLength = sharedLength;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "msgpackr",
3
3
  "author": "Kris Zyp",
4
- "version": "2.0.1",
4
+ "version": "2.0.3",
5
5
  "description": "Ultra-fast MessagePack implementation with extensions for records and structured cloning",
6
6
  "license": "MIT",
7
7
  "types": "./index.d.ts",
@@ -87,7 +87,7 @@
87
87
  "/*.cts"
88
88
  ],
89
89
  "optionalDependencies": {
90
- "msgpackr-extract": "^3.0.2"
90
+ "msgpackr-extract": "^3.0.4"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@rollup/plugin-json": "^5.0.1",