Skip to content

Rethrown error when streaming #397

@BorePlusPlus

Description

@BorePlusPlus

Hello,

Recently I noticed that my streaming download code is "blowing up" the process when trying to download non-existing object (my guess is it's probably same for all error conditions). The stripped down use case looks like this.

'use strict';

var AWS = require('aws-sdk');
var fs = require('fs');

AWS.config.update({
    accessKeyId: 'foo',
    secretAccessKey: 'bar'
});

var s3Client = new AWS.S3();
var devNull = fs.createWriteStream('/dev/null');

function getStream(s3id) {
    var s3DownloadParams = {
        Bucket: 'baz',
        Key: s3id
    };

    return s3Client.getObject(s3DownloadParams)
        .on('error', function () { console.log(':('); })
        .on('success', function () { console.log(':)'); })
        .createReadStream();
}

getStream('non-existing').pipe(devNull);

Pre 1e277ec this just printed the sad face :(, but after that commit the process is killed by an unhandled error, a bit like so:

:(

/home/bore/projects/playground/aws-sdk-js/lib/sequential_executor.js:226
        throw err;
              ^
NoSuchKey: The specified key does not exist.
    at Request.extractError (/home/bore/projects/playground/aws-sdk-js/lib/services/s3.js:306:35)
    at Request.callListeners (/home/bore/projects/playground/aws-sdk-js/lib/sequential_executor.js:102:18)
    at Request.emit (/home/bore/projects/playground/aws-sdk-js/lib/sequential_executor.js:79:10)
    at Request.emit (/home/bore/projects/playground/aws-sdk-js/lib/request.js:595:14)
    at Request.transition (/home/bore/projects/playground/aws-sdk-js/lib/request.js:20:12)
    at AcceptorStateMachine.runTo (/home/bore/projects/playground/aws-sdk-js/lib/state_machine.js:14:12)
    at /home/bore/projects/playground/aws-sdk-js/lib/state_machine.js:26:10
    at Request.<anonymous> (/home/bore/projects/playground/aws-sdk-js/lib/request.js:21:9)
    at Request.<anonymous> (/home/bore/projects/playground/aws-sdk-js/lib/request.js:597:12)
    at Request.callListeners (/home/bore/projects/playground/aws-sdk-js/lib/sequential_executor.js:106:18)

Could you please spare some time to look into this (or suggest alternative implementation)?

Cheers,
Dali

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions