cloudflare-next-intl 0.9.57 → 0.9.58

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.
@@ -9,7 +9,7 @@ const MAX_RECOVERY_ATTEMPTS = 2;
9
9
  const BUILD_ID_KEY = 'buildId';
10
10
  const BUILD_ID_SET_AT_KEY = 'buildIdSetAt';
11
11
  const RECENT_BUILD_WINDOW_MS = 60000;
12
- const RELOAD_THROTTLE_MS = 15000;
12
+ const RELOAD_THROTTLE_MS = 1000;
13
13
  function currentBuildId() {
14
14
  try {
15
15
  return localStorage.getItem(BUILD_ID_KEY) ?? 'unknown';
@@ -20,9 +20,7 @@ export default function HelperScript() {
20
20
  var timeKey = 'stale-deploy-recovery-time';
21
21
  var countKey = 'stale-deploy-recovery-count';
22
22
  var maxAttempts = 3;
23
- var throttleMs = 15000;
24
23
  var attemptedThisLoad = false;
25
- var retryScheduled = false;
26
24
  // Set by the resource-error listener: the first same-origin
27
25
  // chunk that failed. Reloading is pointless until that URL
28
26
  // answers with real JavaScript again, so it doubles as the
@@ -94,11 +92,8 @@ export default function HelperScript() {
94
92
  if (!stale) return;
95
93
  var buildId = localStorage.getItem('buildId') || 'unknown';
96
94
  var marker = sessionStorage.getItem(key);
97
- var lastRaw = sessionStorage.getItem(timeKey);
98
- var last = lastRaw ? Number(lastRaw) : null;
99
- var throttled = last !== null && (Date.now() - last) < throttleMs;
100
- // Attempts are counted per build id: the 1st and 2nd
101
- // page load may each recover, the 3rd falls through to
95
+ // Attempts are counted per build id: the first few
96
+ // page loads may each recover, then it falls through to
102
97
  // the error UI. A new deploy resets the count.
103
98
  var sameBuild = marker === buildId;
104
99
  var attempts = 0;
@@ -111,22 +106,12 @@ export default function HelperScript() {
111
106
  console.warn('[StaleDeploy early-catch] Skipping reload, attempts exhausted for buildId:', buildId, attempts);
112
107
  return;
113
108
  }
114
- // A reload that lands inside the same throttle window
115
- // means the previous recovery did not help: the assets
116
- // are momentarily unreadable at the edge rather than
117
- // stale. Waiting out the window and retrying lets the
118
- // page heal itself instead of stranding the visitor on
119
- // the error UI.
120
- if (sameBuild && throttled) {
121
- if (retryScheduled) return;
122
- retryScheduled = true;
123
- var wait = throttleMs - (Date.now() - last);
124
- if (!(wait > 0)) wait = 0;
125
- console.warn('[StaleDeploy early-catch] Throttled for buildId:', buildId, '- retrying in', wait, 'ms');
126
- showOverlay();
127
- setTimeout(function() { retryScheduled = false; recover(msg, source); }, wait + 250);
128
- return;
129
- }
109
+ // No time-based throttle: the probe below already
110
+ // paces the retry and refuses to reload until the asset
111
+ // is readable, so a clock-based wait only strands the
112
+ // visitor on the overlay for the rest of the window.
113
+ // attemptedThisLoad stops a burst within one load and
114
+ // maxAttempts stops a reload loop across loads.
130
115
  attemptedThisLoad = true;
131
116
  sessionStorage.setItem(key, buildId);
132
117
  sessionStorage.setItem(countKey, String(attempts + 1));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.9.57",
3
+ "version": "0.9.58",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",