Fix: TextWriterFluidOutput.Dispose() requires force sync (#919)#920
Merged
sebastienros merged 1 commit intomainfrom Feb 16, 2026
Merged
Fix: TextWriterFluidOutput.Dispose() requires force sync (#919)#920sebastienros merged 1 commit intomainfrom
sebastienros merged 1 commit intomainfrom
Conversation
IAsyncDisposable implementation to TextWriterFluidOutput with a DisposeAsync() method that properly handles async flushing.
**PR Title:**
fix: add IAsyncDisposable to TextWriterFluidOutput for async flush
This title:
- Uses conventional commit format (fix:)
- Is under 72 characters (54 chars)
- Describes the specific change (adding async disposable support)
- Relates to issue #919 about the dispose requiring force sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary of Changes
This PR adds
IAsyncDisposablesupport toTextWriterFluidOutputand updates all usages to useawait usinginstead ofusingto ensure fully asynchronous disposal.Key changes:
IAsyncDisposableinterface implementation toTextWriterFluidOutputwithDisposeAsync()methodawait usingpattern:FluidRendering.cs(MVC View Engine)FluidViewRenderer.cs(View Engine - bothRenderViewAsyncandRenderPartialAsync)FluidOutputExtensions.cs(3 extension methods)FluidTemplateExtensions.csActionViewResult.cs(Minimal APIs)TextWriterFluidOutputTests.cs- 1073 lines)FluidOutputIntegrationTests.cs- 498 lines)Motivation and Context
Fixes #919
ASP.NET Core disables synchronous I/O by default (
IHttpBodyControlFeature.AllowSynchronousIO = false). The v3.0.0-beta4 release introducedTextWriterFluidOutputwhich used synchronousDispose()that internally calledFlushCore()with synchronous writes. This causedSystem.InvalidOperationException: Synchronous operations are disallowederrors when rendering Liquid templates in ASP.NET Core applications, particularly when response compression (e.g., Brotli) was enabled.How the Changes Were Tested
Added
TextWriterFluidOutputTests.cswith comprehensive unit tests covering:DisposeAsync()behavior and buffer cleanupAdded
FluidOutputIntegrationTests.cswith integration tests covering:Screenshots
N/A - Internal API change, no UI impact.
Checklist
IAsyncDisposableonTextWriterFluidOutputusingstatements toawait usingfor async disposalDispose()still available)#if NETSTANDARD2_0conditional compilation