[release/6.0.4xx] Backport '[Blazor WASM] Don't apply hot reload deltas if Blazor has not been initialized' #33160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Blazor WASM] Don't apply hot reload deltas if Blazor has not been initialized
Backport of #33122.
Fixes an issue where hot reload fails if the browser receives hot reload deltas before Blazor WebAssembly initializes.
Description
If this bug occurs when debugging with Visual Studio, an exception message like the following gets shown:
This forces the customer to restart the app for hot reload to continue working.
The fix simply ignores the received deltas if Blazor has not been initialized to the point where it's ready to apply hot reload updates. Blazor already has logic to apply all previously received hot reload updates upon initialization, so the changes will take effect anyway as soon as Blazor completes its boot procedure.
Fixes https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1779975
Customer Impact
Moderate. This exception can be triggered easily when debugging web apps that load Blazor WebAssembly only on specific pages. For apps completely written in Blazor WebAssembly, the exception is more difficult to encounter.
If the bug is encountered, a full app restart is required to use hot reload again.
Regression?
Risk
The fix is straightforward and unlikely to introduce a new regression.
Verification
Packaging changes reviewed?