Don't start stream if already canceled (#2764)
This commit is contained in:
parent
186a85b7e0
commit
2265acde78
|
|
@ -420,6 +420,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
|||
{
|
||||
CheckDisposed();
|
||||
CheckConnectionActive(nameof(StreamAsChannelCoreAsync));
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var irq = InvocationRequest.Stream(cancellationToken, returnType, _connectionState.GetNextId(), _loggerFactory, this, out channel);
|
||||
await InvokeStreamCore(methodName, irq, args, cancellationToken);
|
||||
|
|
|
|||
|
|
@ -398,15 +398,8 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(HubProtocolsAndTransportsAndHubPaths))]
|
||||
public async Task StreamDoesNotStartIfTokenAlreadyCanceled(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
bool ExpectedErrors(WriteContext writeContext)
|
||||
{
|
||||
return (writeContext.LoggerName == nameof(Http.Connections.Client.Internal.ServerSentEventsTransport) ||
|
||||
writeContext.LoggerName == nameof(Http.Connections.Client.Internal.LongPollingTransport)) &&
|
||||
writeContext.EventId.Name == "ErrorSending";
|
||||
}
|
||||
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(StreamDoesNotStartIfTokenAlreadyCanceled)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
|
||||
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(StreamDoesNotStartIfTokenAlreadyCanceled)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
|
||||
{
|
||||
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
|
||||
try
|
||||
|
|
@ -416,10 +409,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
var cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
|
||||
var channel = await connection.StreamAsChannelAsync<int>("Stream", 5, cts.Token).OrTimeout();
|
||||
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(() =>
|
||||
channel.WaitToReadAsync().AsTask().OrTimeout());
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(() =>connection.StreamAsChannelAsync<int>("Stream", 5, cts.Token).OrTimeout());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue