Repository navigation
Fix orphaned RemoteJSDataStream when sendJSDataStream initiation throws - #69871
Conversation
|
Thanks for your PR, @irfanajaffer. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
🔵 Needs a closer look
The required frozen review evidence was not supplied, leaving approval checks incomplete.
0 open findings
What changed in this PR
Addresses #69838 by cleaning up Blazor Server streams when JavaScript transfer initiation fails.
Changes:
- Disposes the partially created stream before rethrowing the initiation exception.
- Adds synchronous and asynchronous failure coverage for cleanup, exception preservation, and timeout handling.
| File | Description |
|---|---|
| src/Components/Server/test/Circuits/RemoteJSDataStreamTest.cs | Adds initiation-failure regression tests. |
| src/Components/Server/src/Circuits/RemoteJSDataStream.cs | Cleans up streams when initiation throws. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
kotlarmilos
left a comment
There was a problem hiding this comment.
Please drop the test, not needed
|
Project status update: the latest maintainer review asks to drop the test, and there has not been an author update after that review. I moved the PR and its linked issue to In progress on the Blazor Syncfusion project. Please address the review feedback, then move it back to In review when it is ready for another review. |
|
/azp run aspnetcore-components-e2e |
|
Commenter does not have sufficient privileges for PR 69871 in repo dotnet/aspnetcore |
|
Copilot's local review panel found no issues to raise at this commit. |
|
✅ No documentation PR was created. Confidence that documentation is needed: 5% No docs needed: the single changed file adds try/catch cleanup of a partially created RemoteJSDataStream. It's an internal fix, not insufficient evidence. Documentation surfaces considered
|
Description
Fixes an issue where a failed
sendJSDataStreaminitiation leaves aRemoteJSDataStreamorphaned and can subsequently terminate the Blazor Server circuit.When
RemoteJSDataStream.CreateRemoteJSDataStreamAsynccreates a new stream instance, it registers the stream with the runtime before invoking the JavaScript-sideBlazor._internal.sendJSDataStreaminitialization. If that JS interop call throws, the stream instance remains registered and is never cleaned up. The orphaned stream can later trigger timeout/disposal logic that raises an unhandled exception and ends the circuit unexpectedly.This change ensures that failures during stream initiation are handled correctly by cleaning up the partially-created stream before rethrowing the original exception.
Root Cause
CreateRemoteJSDataStreamAsynccreates and registers aRemoteJSDataStreaminstance before starting the JS-side transfer:If
InvokeVoidAsync("Blazor._internal.sendJSDataStream", ...)throws, execution exits immediately and the created stream remains tracked inRemoteJSRuntime.RemoteJSDataStreamInstances. Since the stream was never fully initialized nor disposed, its timeout/disposal path can later raise an unhandled exception, causing the circuit to terminate.The fix wraps the initiation call in a
try/catchblock and explicitly disposes the stream when initiation fails:This ensures:
After Fix
sendJSDataStreaminitialization correctly cleans up the createdRemoteJSDataStream.RemoteJSRuntime.RemoteJSDataStreamInstances.Testing
Added regression coverage for stream initiation failures:
CreateRemoteJSDataStreamAsync_DisposesStream_WhenSendJSDataStreamThrows.sendJSDataStreaminitialization throws.Validation Performed
Before Fix
Before.fix.-.69838.mp4
After Fix
Aftre.fix.-.69838.mp4
Fixes #69838