Skip to content

Streaming request BodyStream never read #282

@aajtodd

Description

@aajtodd

Describe the bug

When using a streaming request body (something that implements ByteStream.Streaming) we use ReadChannelBodyStream to proxy the request body to CRT.

What appears to be happening is that the CRT endlessly calls sendRequestBody in a loop until all of the content has been read. The issue with this is that if the original coroutine and the coroutine launched to proxy the request share the same CoroutineDispatcher then the proxy coroutine will never get a chance to run because sendRequestBody effectively needs to suspend/yield to allow the dispatcher to do other work.

S3.putObject with ByteStream.fromFile(...) can trigger this and how I found it but I don't have a concrete reproducible test case since it does not happen every time depending on whether or not the proxy coroutine ever suspends or not (e.g. it will succeed if the first loop through it doesn't suspend AND it reads the entire file contents).

Possible solution

We may have to give the proxy coroutine a dedicated dispatcher or figure out how to do a yield() from the CRT thread...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions