minerender 2.1.0-alpha.145 → 2.1.0-alpha.146

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.
@@ -11561,6 +11561,7 @@ init_PersistentCache();
11561
11561
  var NodeCache = class extends PersistentCache {
11562
11562
  constructor(backing) {
11563
11563
  super(backing);
11564
+ this.pendingWrites = /* @__PURE__ */ new Map();
11564
11565
  }
11565
11566
  ready() {
11566
11567
  return this.initialized ??= this.backing.init();
@@ -11571,7 +11572,14 @@ var NodeCache = class extends PersistentCache {
11571
11572
  }
11572
11573
  async put(key, value) {
11573
11574
  await this.ready();
11574
- return this.backing.setItem(key, value).then((res) => res.content);
11575
+ const previous = this.pendingWrites.get(key);
11576
+ const write = (previous ? previous.catch(() => void 0) : Promise.resolve()).then(() => this.backing.setItem(key, value)).then(() => value);
11577
+ this.pendingWrites.set(key, write);
11578
+ try {
11579
+ return await write;
11580
+ } finally {
11581
+ if (this.pendingWrites.get(key) === write) this.pendingWrites.delete(key);
11582
+ }
11575
11583
  }
11576
11584
  async delete(key) {
11577
11585
  await this.ready();
@@ -11617,7 +11625,10 @@ var NodeEnv = class {
11617
11625
  openCache(name, version2) {
11618
11626
  return new NodeCache(NodePersist.create({
11619
11627
  dir: name + version2,
11620
- encoding: "utf8"
11628
+ encoding: "utf8",
11629
+ // node-persist's unref'd one-second write queue delays loads and lets Node exit before writes finish.
11630
+ // NodeCache serializes writes to each key while allowing different files to write concurrently.
11631
+ writeQueue: false
11621
11632
  }));
11622
11633
  }
11623
11634
  };