-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
S3 Upload API fails with ERR_STREAM_WRITE_AFTER_END #3404
Comments
Hey @juanantoniofj thanks for bringing this up, I was not able to reproduce this and I used a fairly large file. The code I used:
I believe this is more related to how the code is written. Please feel free to reach out if you have more inputs. |
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing. |
I can consistently reproduce this with node v14.15.4 and Linode Object Storage. Curiously, I can upload fine to other object storages just fine (DO, S3, Minio to name a few). I am using [email protected]. The back trace is similar:
|
I tried to make a minimal example and it seems I can upload simple files just fine. In my code, it's the equivalent of "tar cvf - | s3_uploader". Looks like something with the source stream causes this issue. I will continue to try to make a minimal example. |
Yes, the error is related to node v14. S3 relies on HTTP 100-continue for large files and aws-sdk is ending the pipe before it has finished. Probably not the cleanest solution but I was able to fix this as follow:
|
@juanantoniofj amazing! I can confirm your patch works. Can someone from the AWS team re-open this bug and also comment on the patch? Thanks! |
#437 added 100-continue by default. |
I narrowed this problem to Linode Object Storage sending
This causes the code here to pipe the body twice and this results in an error. I have also left a note at https://www.linode.com/community/questions/21180/object-storage-upload-err_stream_write_after_end-write-after-end#answer-75978 . I don't know if the above is correct HTTP or not. |
Linode Object Storage sends multiple '100 continue' lines as a response to 'Expect: 100-continue'. This causes node.js to parse the response correctly and fire the 'continue' event twice. See also aws#3404
Linode Object Storage sends multiple '100 continue' lines as a response to 'Expect: 100-continue'. This causes node.js to parse the response correctly and fire the 'continue' event twice. See also aws#3404
I have reopened the issue, sorry for the delay, but is this still a problem? |
@ajredniwja thanks for re-opening. Yes, this is this a problem and easily reproduced with Linode Object Storage. I have submitted a PR at #3674 . Linode servers respond like below to
|
@ajredniwja this is still a problem, any thoughts on this? |
I havent reproduced it with Linode Object Storage as I am not so familiar with that. @gramakri |
Linode Object Storage sends multiple '100 continue' lines as a response to 'Expect: 100-continue'. This causes node.js to parse the response correctly and fire the 'continue' event twice. See also #3404
I was having the same problem and, testing this branch from this fork, it worked perfectly |
@ajredniwja #3674 is merged now, so this issue can be closed. |
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
Uploading large files of a few megabytes of size using the upload aws-sdk s3 API throws UnhandledPromiseRejectionWarning with ERR_STREAM_WRITE_AFTER_END and
Is the issue in the browser/Node.js?
Node.js
Details of the browser/Node.js version
Node.js v14.8.0
SDK version number
[email protected]
To Reproduce (observed behavior)
Upload a file of 2MB passing Body param with type ReadableStream.
Exception thrown:
Additional context
I think the error is easy to be tracked down to the cases where long files upload triggers 100-Continue what executes https://github.com/aws/aws-sdk-js/blob/master/lib/http/node.js#L100 and https://github.com/aws/aws-sdk-js/blob/master/lib/http/node.js#L137 ending the stream before write ends.
The text was updated successfully, but these errors were encountered: