Skip to content

Commit e2bca6d

Browse files
author
Martii
committed
Graceful failure when S3 *(fake or real)* doesn't have key
* Directly related to #37. Stops net timeout when picking some other script that isn't present in fakeS3. Eventually when *aws-sdk* is updated this will be needed so it doesn't halt dev. Possibly applicable routine to #486 for inline live migration
1 parent cc99cac commit e2bca6d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

controllers/scriptStorage.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,24 @@ exports.getSource = function (aReq, aCallback) {
5050

5151
Script.findOne({ installName: caseInsensitive(installName) },
5252
function (aErr, aScript) {
53+
var s3Object = null;
54+
5355
if (!aScript) {
5456
return aCallback(null);
5557
}
5658

59+
s3Object = s3.getObject({ Bucket: bucketName, Key: installName }).createReadStream().
60+
on('error', function () {
61+
if (isPro) {
62+
console.error('S3 Key Not Found ' + installName);
63+
}
64+
65+
return aCallback(null);
66+
});
67+
5768
// Get the script
58-
aCallback(aScript, s3.getObject({ Bucket: bucketName, Key: installName })
59-
.createReadStream());
60-
});
69+
aCallback(aScript, s3Object);
70+
});
6171
};
6272

6373
exports.sendScript = function (aReq, aRes, aNext) {

0 commit comments

Comments
 (0)