Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/BuiltInTools/BrowserRefresh/WebSocketScriptInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,25 @@ setTimeout(async function () {
}

let applyFailed = false;
deltas.forEach(d => {
try {
window.Blazor._internal.applyHotReload(d.moduleId, d.metadataDelta, d.ilDelta, d.pdbDelta)
} catch (error) {
console.warn(error);
applyFailed = true;
}
});
if (window.Blazor?._internal?.applyHotReload) {
// Only apply hot reload deltas if Blazor has been initialized.
// It's possible for Blazor to start after the initial page load, so we don't consider skipping this step
// to be a failure. These deltas will get applied later, when Blazor completes initialization.
deltas.forEach(d => {
try {
window.Blazor._internal.applyHotReload(d.moduleId, d.metadataDelta, d.ilDelta, d.pdbDelta)
} catch (error) {
console.warn(error);
applyFailed = true;
}
});
}

fetch('/_framework/blazor-hotreload', { method: 'post', headers: { 'content-type': 'application/json' }, body: JSON.stringify(deltas) })
.then(response => {
if (response.status == 200) {
const etag = response.headers['etag'];
window.sessionStorage.setItem('blazor-webasssembly-cache', { etag, deltas });
window.sessionStorage.setItem('blazor-webassembly-cache', { etag, deltas });
}
});

Expand Down