@camstack/types 0.1.16 → 0.1.18

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const authRecords = require("./auth-records-D5ZNaUos.js");
3
+ const authRecords = require("./auth-records-dZTcJ-2e.js");
4
4
  const zod = require("zod");
5
5
  class DisposerChain {
6
6
  disposers = [];
@@ -545,7 +545,7 @@ class BaseAddon {
545
545
  * (e.g. from older versions) without polluting the typed config.
546
546
  */
547
547
  async resolveConfig() {
548
- const stored = await this._ctx?.settings?.readAddonStore() ?? {};
548
+ const stored = await this.readAddonStoreWithRetry();
549
549
  const resolved = { ...this.defaults };
550
550
  for (const key of Object.keys(this.defaults)) {
551
551
  const storedValue = stored[key];
@@ -558,6 +558,39 @@ class BaseAddon {
558
558
  }
559
559
  this._config = resolved;
560
560
  }
561
+ /**
562
+ * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
563
+ * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
564
+ * swap, or any race where the SqliteSettingsBackend is between shutdown and
565
+ * re-initialize) doesn't propagate up into `initialize()` and leave the
566
+ * addon permanently broken.
567
+ *
568
+ * Retry only the two known infra fingerprints. Anything else propagates so
569
+ * real bugs surface immediately. After the budget expires we fall back to
570
+ * `{}` (defaults) — the addon's first successful patch will rehydrate.
571
+ */
572
+ async readAddonStoreWithRetry() {
573
+ const settings = this._ctx?.settings;
574
+ if (!settings) return {};
575
+ const delaysMs = [150, 350, 600, 900];
576
+ let lastErr;
577
+ for (let attempt = 0; attempt <= delaysMs.length; attempt++) {
578
+ try {
579
+ return await settings.readAddonStore() ?? {};
580
+ } catch (err) {
581
+ lastErr = err;
582
+ const msg = err instanceof Error ? err.message : String(err);
583
+ const transient = msg.includes("SqliteSettingsBackend not initialized") || msg.includes("provider not available");
584
+ if (!transient) throw err;
585
+ if (attempt === delaysMs.length) break;
586
+ await new Promise((r) => setTimeout(r, delaysMs[attempt]));
587
+ }
588
+ }
589
+ this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", {
590
+ meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) }
591
+ });
592
+ return {};
593
+ }
561
594
  }
562
595
  function normalizeAddonInitResult(result) {
563
596
  if (result == null) return;