-
Notifications
You must be signed in to change notification settings - Fork 55
Description
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...