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 =
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
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));
|