@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.
package/lib/client.js CHANGED
@@ -212,7 +212,7 @@ const AUXILIARY_MODEL_CHANGES_IDENTITY = modelSettingsChangesIdentity("@klarkxy/
212
212
  //#endregion
213
213
  //#region ../dsh-plugin-kit/src/client-utils.ts
214
214
  /** Fixed pause for failing background reads; manual work is never replayed. */
215
- function createPluginReadGate(now = Date.now) {
215
+ function createPluginReadGate(now = Date.now, logger) {
216
216
  let pausedUntil = 0;
217
217
  let epoch = 0;
218
218
  return {
@@ -225,11 +225,17 @@ function createPluginReadGate(now = Date.now) {
225
225
  const current = epoch;
226
226
  try {
227
227
  const value = await read();
228
- if (current === epoch) pausedUntil = 0;
228
+ if (current === epoch) {
229
+ if (pausedUntil > 0) logger?.debug("read-gate.resumed", "Background read gate recovered.");
230
+ pausedUntil = 0;
231
+ }
229
232
  return value;
230
233
  } catch (error) {
231
234
  const message = error instanceof Error ? error.message : "";
232
- 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;
235
+ 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))) {
236
+ pausedUntil = now() + 3e4;
237
+ logger?.warn("read-gate.paused", "Background reads paused for 30s after transport failure.", error);
238
+ }
233
239
  throw error;
234
240
  }
235
241
  }