Skip to content

Stream aborted if QuicStream.WriteAsync cancellation token is canceled after WriteAsync completes #82704

@bentoi

Description

@bentoi

Description

A quic stream can be aborted even if the cancellation token provided to QuicStream.WriteAsync is canceled after WriteAsync completes.

Reproduction Steps

See attached test case.

quicabortread.zip

Expected behavior

Since WriteAsync successfully completed, it shouldn't trigger the stream abort if the cancellation token source is canceled after.

Actual behavior

Test case shows:

Unhandled exception. System.Net.Quic.QuicException: Stream aborted by peer (58).
   at System.Net.Quic.ResettableValueTaskSource.TryComplete(Exception exception, Boolean final)
   at System.Net.Quic.QuicStream.HandleEventPeerSendAborted(_PEER_SEND_ABORTED_e__Struct& data)
   at System.Net.Quic.QuicStream.HandleStreamEvent(QUIC_STREAM_EVENT& streamEvent)
   at System.Net.Quic.QuicStream.NativeCallback(QUIC_HANDLE* connection, Void* context, QUIC_STREAM_EVENT* streamEvent)
--- End of stack trace from previous location ---
   at System.Net.Quic.ResettableValueTaskSource.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Quic.QuicStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 49
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 50
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 43
   at Program.Main(String[] args) in /home/vagrant/workspace/quicabortread/Program.cs:line 43
   at Program.<Main>(String[] args)

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK:
 Version:   7.0.200
 Commit:    534117727b

Runtime Environment:
 OS Name:     debian
 OS Version:  10
 OS Platform: Linux
 RID:         debian.10-x64
 Base Path:   /home/vagrant/dotnet/sdk/7.0.200/

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions