Skip to content

Commit 1ae4d9e

Browse files
authored
Merge pull request #992 from codemonkey85/dev
Retry dotnetjs boot resource; add reload hint for network startup errors
2 parents 57ba4b1 + 8e264a3 commit 1ae4d9e

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

Pkmds.Web/wwwroot/index.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,19 @@
185185

186186
Blazor.start({
187187
loadBootResource: function (type, name, defaultUri, integrity) {
188-
// The 'dotnetjs' module is imported as a script and must be
189-
// returned as a URL string, not a Response — leave it to the
190-
// default loader.
191188
if (type === 'dotnetjs') {
192-
return undefined;
189+
// dotnetjs must be returned as a URL string (or Promise<string>),
190+
// not a Response. Pre-fetch with retry (and SRI when integrity is
191+
// supplied) so a transient failure gets multiple attempts; reject
192+
// explicitly on non-OK so bootstrap fails with a clear error rather
193+
// than silently returning the URL and letting the script import fail
194+
// generically later (issue #991).
195+
return retryFetchBootResource(defaultUri, integrity).then(function (response) {
196+
if (!response.ok) {
197+
throw new TypeError('dotnetjs load failed: HTTP ' + response.status);
198+
}
199+
return defaultUri;
200+
});
193201
}
194202
return retryFetchBootResource(defaultUri, integrity);
195203
}

Pkmds.Web/wwwroot/js/error-reporting.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,21 @@
8282
ui.insertBefore(details, msgEl.nextSibling);
8383
}
8484

85-
// Button row.
85+
// For network-layer startup failures, add a reload hint before the
86+
// button row so users know what to try before filing a bug.
87+
var isNetworkError = (
88+
message === 'Load failed' ||
89+
message.indexOf('Failed to fetch') !== -1 ||
90+
message.indexOf('NetworkError') !== -1
91+
);
92+
if (isNetworkError) {
93+
var hint = document.createElement('p');
94+
hint.style.cssText = 'margin: 0.4rem 0 0; font-size: 0.8rem; color: #555;';
95+
hint.textContent = 'This is usually a temporary network problem or an app update in progress — reloading typically fixes it.';
96+
ui.insertBefore(hint, (stack ? details : msgEl).nextSibling);
97+
}
98+
99+
// Button row — anchor after hint when present (var-hoisted as undefined otherwise).
86100
var row = document.createElement('div');
87101
row.style.cssText = 'margin-top: 0.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;';
88102

@@ -120,7 +134,7 @@
120134
row.appendChild(copyBtn);
121135
row.appendChild(reportLink);
122136

123-
var insertAfter = stack ? details : msgEl;
137+
var insertAfter = hint || (stack ? details : msgEl);
124138
ui.insertBefore(row, insertAfter.nextSibling);
125139
}
126140

0 commit comments

Comments
 (0)