Skip to content

Commit c89cd57

Browse files
committed
@javiercn's fixes
1 parent 95ac585 commit c89cd57

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ internal partial class EndpointHtmlRenderer : StaticHtmlRenderer, IComponentPrer
4343
private Task? _servicesInitializedTask;
4444
private HttpContext _httpContext = default!; // Always set at the start of an inbound call
4545
private ResourceAssetCollection? _resourceCollection;
46+
private bool _rendererIsStopped;
4647

4748
// The underlying Renderer always tracks the pending tasks representing *full* quiescence, i.e.,
4849
// when everything (regardless of streaming SSR) is fully complete. In this subclass we also track
@@ -177,8 +178,16 @@ protected override void AddPendingTask(ComponentState? componentState, Task task
177178

178179
private void StopRenderer()
179180
{
180-
_nonStreamingPendingTasks.Clear();
181-
Dispose();
181+
_rendererIsStopped = true;
182+
}
183+
184+
protected override void ProcessPendingRender()
185+
{
186+
if (_rendererIsStopped)
187+
{
188+
return;
189+
}
190+
base.ProcessPendingRender();
182191
}
183192

184193
// For tests only
@@ -188,7 +197,7 @@ protected override Task UpdateDisplayAsync(in RenderBatch renderBatch)
188197
{
189198
UpdateNamedSubmitEvents(in renderBatch);
190199

191-
if (_streamingUpdatesWriter is { } writer)
200+
if (_streamingUpdatesWriter is { } writer && !_rendererIsStopped)
192201
{
193202
// Important: SendBatchAsStreamingUpdate *must* be invoked synchronously
194203
// before any 'await' in this method. That's enforced by the compiler

src/Components/test/E2ETest/Tests/GlobalInteractivityTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ public void CanRenderNotFoundInteractive(string renderingMode, bool isInteractiv
4444
public async Task CanSetNotFoundStatus()
4545
{
4646
var statusCode = await GetStatusCodeAsync($"/subdir/render-not-found-ssr");
47-
// problem: subscription to OnNotFound queued the render event at the time when the renderer was not disposed and wants to render when it already is (we dispose of it in SetNotFoundResponse)
48-
// fragment rendering does not make sense in this case but how to prevent it?
4947
Assert.Equal(HttpStatusCode.NotFound, statusCode);
5048
}
5149

0 commit comments

Comments
 (0)