@klarkxy/dsh-current-title 0.3.4 → 0.3.5

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.
@@ -206,7 +206,7 @@ const AUXILIARY_MODEL_CHANGES_IDENTITY = modelSettingsChangesIdentity("@klarkxy/
206
206
  //#endregion
207
207
  //#region ../dsh-plugin-kit/src/client-utils.ts
208
208
  /** Fixed pause for failing background reads; manual work is never replayed. */
209
- function createPluginReadGate(now = Date.now) {
209
+ function createPluginReadGate(now = Date.now, logger) {
210
210
  let pausedUntil = 0;
211
211
  let epoch = 0;
212
212
  return {
@@ -219,11 +219,17 @@ function createPluginReadGate(now = Date.now) {
219
219
  const current = epoch;
220
220
  try {
221
221
  const value = await read();
222
- if (current === epoch) pausedUntil = 0;
222
+ if (current === epoch) {
223
+ if (pausedUntil > 0) logger?.debug("read-gate.resumed", "Background read gate recovered.");
224
+ pausedUntil = 0;
225
+ }
223
226
  return value;
224
227
  } catch (error) {
225
228
  const message = error instanceof Error ? error.message : "";
226
- if (current === epoch && (/(?:^|\s)transport failure for .+: HTTP (?:404|405|503)\b/.test(message) || error instanceof TypeError && /^(?:Failed to fetch|fetch failed|NetworkError when attempting to fetch resource\.?)$/i.test(message))) pausedUntil = now() + 3e4;
229
+ if (current === epoch && (/(?:^|\s)transport failure for .+: HTTP (?:404|405|503)\b/.test(message) || error instanceof TypeError && /^(?:Failed to fetch|fetch failed|NetworkError when attempting to fetch resource\.?)$/i.test(message))) {
230
+ pausedUntil = now() + 3e4;
231
+ logger?.warn("read-gate.paused", "Background reads paused for 30s after transport failure.", error);
232
+ }
227
233
  throw error;
228
234
  }
229
235
  }