-
Notifications
You must be signed in to change notification settings - Fork 316
Description
Observed
The Client.putObject sometimes (often) stalls when given a destroyed stream.
Expected
The Client.putObject throws an error if a non-readable stream is found.
Notes
In my opinion, there are two problems in the Client.putObject function regarding stream error handling.
First: The isReadableStream check is not sufficient. If a destroyed stream gets checked by isReadableStream, it will return true which is wrong. In that case the function putObject will stall forever, because it tries to read a non-readable stream. Possible fix: Use isReadable from the nodejs library.
Second: Even if the isReadableStream check would work, it would be possible that the stream is destroyed after the check but before the Error listener. In that case the library would stall forever again. Note: This was not a problem in older versions before the async calls findUploadId, initiateNewMultipartUpload and listParts got added, since the node eventloop helped us here. However, now this is a problem. Possible fix: Listen to errors earlier (which might be hard to enforce for future changes). Therefore, second option: Use the isReadable check again.