Skip to content

Commit

Permalink
Merge pull request #1169 from jbergknoff/stream-error-propagation
Browse files Browse the repository at this point in the history
Propagate an error from a stream to s3.upload callback
  • Loading branch information
chrisradek authored Oct 13, 2016
2 parents 471dd1a + 32ca3ff commit 557c0c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-s3-20314e6c.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "s3",
"description": "Propagate an error from a stream to s3.upload callback #1169"
}
1 change: 1 addition & 0 deletions lib/s3/managed_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ AWS.S3.ManagedUpload = AWS.util.inherit({
self.fillQueue = self.fillStream;
self.partBuffers = [];
self.body.
on('error', function(err) { self.cleanup(err); }).
on('readable', function() { self.fillQueue(); }).
on('end', function() {
self.isDoneChunking = true;
Expand Down
11 changes: 11 additions & 0 deletions test/s3/managed_upload.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,14 @@ describe 'AWS.S3.ManagedUpload', ->
expect(helpers.operationsForRequests(reqs)).to.eql ['s3.putObject']
expect(err).not.to.exist
done()

it 'propagates an error from a stream', (done) ->
errorStream = new require('stream').Readable()
errorStream._read = -> this.emit('error', new Error('message'))

upload = new AWS.S3.ManagedUpload params: { Body: errorStream }
upload.send (e, d) ->
expect(e).to.exist
expect(d).not.to.exist
expect(e.message).to.equal('message')
done()

0 comments on commit 557c0c8

Please sign in to comment.