Skip to content
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

LZ4EncoderStream Dispose Issue #85

Closed
rajeshgaddam17 opened this issue Aug 9, 2023 · 3 comments
Closed

LZ4EncoderStream Dispose Issue #85

rajeshgaddam17 opened this issue Aug 9, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@rajeshgaddam17
Copy link

Description
Trying to use LZ4EncoderStream to compress and decompress but when using it we are getting below exception
System.Net.Http.HttpRequestException : Error while copying content to a stream.
----> System.IO.IOException : No message provided
----> System.InvalidOperationException : Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true.

To reproduce
Calling this method context.HttpContext.Response.Body.WriteAsync(byteArray, 0, byteArray.Length);

and it is using LZ4Stream.Encode(stream, null, leaveOpen: true); method to do the job but it is failing with above exception.

I have analysed the LZ4EncoderStream.cs class and it is trying to use DisposeAsync() method and inside that it is using _writer.Dispose() insteady of _writer.DisposeAsync() hence it is complaining that Synchronous operations are disallowed.

Pleas see below code

public override ValueTask DisposeAsync()
{
	_writer.Dispose();
	return base.DisposeAsync();
}

Line no 59 in LZ4EncoderStream.cs class

Expected behavior
Expected compression to work when using WriteAsync() method

Actual behavior
Throw below exception

System.Net.Http.HttpRequestException : Error while copying content to a stream.
----> System.IO.IOException : No message provided
----> System.InvalidOperationException : Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true.

Environment

  • CPU: _ [Intel 64 bit]
  • OS: _ [Windows]
  • .NET: _ [6]
  • LZ4: _ [1.3.5]

Additional context
Add any other context about the problem here.

@MiloszKrajewski
Copy link
Owner

Thanks for reporting. Will take a look next week.

MiloszKrajewski added a commit that referenced this issue Aug 15, 2023
@MiloszKrajewski
Copy link
Owner

I hope it has been addressed in 1.3.6, let me know.

@MiloszKrajewski MiloszKrajewski added the bug Something isn't working label Aug 17, 2023
@rajeshgaddam17
Copy link
Author

Yes, It is fixed now. Thanks for looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants