-
Notifications
You must be signed in to change notification settings - Fork 766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration-Test with grpc server does cancel streamed requests. #738
Comments
Logging would help here, please try the instructions at https://docs.microsoft.com/en-us/aspnet/core/grpc/diagnostics?view=aspnetcore-3.1#grpc-client-logging. |
Alright, here are the logs: Locally (which works):
(I did rethrow the exception on purpose to see the log output) Now on the ci pipeline the following happens:
As it seems, there is something happening with the The code that processes the stream is the following: private async Task<StoredFile> ProcessStream<TChunk>(
StoredFile file,
Func<TChunk, byte[]?> processChunk,
IAsyncStreamReader<TChunk> dataStream)
{
var pipe = new Pipe();
var uploadTask = _s3Storage.UploadFile(file.Id, file.Size, pipe.Reader.AsStream());
await foreach (var chunk in dataStream.ReadAllAsync())
{
var data = processChunk(chunk);
if (data == null)
{
continue;
}
if (string.IsNullOrWhiteSpace(file.MimeType))
{
file.MimeType = _interrogator.DetectType(data)?.MimeType ?? DefaultMimeType;
_logger.LogTrace($"Set file-type to {file.MimeType}.");
}
_logger.LogTrace($"Upload chunk for file {file.Id} with {data.Length} bytes.");
await pipe.Writer.WriteAsync(new ReadOnlyMemory<byte>(data));
}
await Task.WhenAll(pipe.Writer.CompleteAsync().AsTask(), uploadTask);
_logger.LogDebug(
$"Upload completed for file {file.Id} with mime type '{file.MimeType}' and size {file.Size}");
return file;
} Is this, because we don't check for the cancellation (in the await foreach) or is it in the underlaying grpc methods? |
Ah I think this is a bug we recently fixed: #723. Please try the next release or a nightly build: https://github.com/grpc/grpc-dotnet#grpc-nuget-feed |
Were you able to try the nightly packages @buehler ? |
Not until today... Going to test it and give you feedback @JunTaoLuo |
You don't need to use a nightly build. 2.27.0 on NuGet contains that fix. |
I upgraded everything to
This seems to be cancelled before the status is returned. Do you need additional logs ? cc @JamesNK cc @JunTaoLuo |
I'm pretty sure the problem is that the test server doesn't handle a request that is streaming content to the server, and your call uses client streaming. There is a bugfix in 3.1.2 for this. I have added tests for server errors to this test PR - #668. You could try updating to 3.1 and referencing 3.1.2 of Microsoft.AspNetCore.TestHost. You'll need to get it from a preview feed that you can see in the PR. Alternatively you can wait a week or two until 3.1.2 is released publically. |
Alright, it is already 3.1, so I'm waiting for 3.1.2. I'll give you guys feedback as soon as I can. Thanks for the help |
This is fixed in 3.1.2 which should be released now! |
@anurse Let me check... |
Nice, it seems to be working. Thanks to all participants! |
Dear grpc dotnet team.
I'm currently using aspnet.grpc with .net core 3.1 and I did catch some strange behaviour.
When using the testing framework of asp.net core to create integration tests, any call that uses serverside or client side streams is cancelled instead of correctly resolved.
Funny enough, when running the tests locally on the developer workstation it does run as intended and when running the tests on ci in docker build, they fail and are cancelled.
Parallel testing is disabled and everything should run serial.
An example of such a test is:
This test is intended for a storage system that has file information. Now when a file is deleted, obviously the correct
RpcException
would beNotFound
. But on CI the result is anRpcException
withCancelled
. It's the horror to debug since it does work as intended locally and the debugger does step to the correct elements.Do you guys have any idea what could go sideways with those calls? Or something that I need to change?
Regards
Chris
The text was updated successfully, but these errors were encountered: