Skip to content

Commit

Permalink
Propagate an error from a stream to s3.upload callback
Browse files Browse the repository at this point in the history
  • Loading branch information
jbergknoff committed Oct 7, 2016
1 parent b0de518 commit 0794efa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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 0794efa

Please sign in to comment.