Skip to content

Commit

Permalink
Fix dual-callback case (#3537)
Browse files Browse the repository at this point in the history
This fixes a bug where using the callback version of createPresignedPost
without proper AWS credentials configured would result in an
un-catchable error and crash the node process.

It is not possible to write a test to capture this error due to the
nature of the error.  The callback is called, and only after that does
the crash occur.
  • Loading branch information
slifty committed Dec 4, 2020
1 parent b981971 commit 71d6fa9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-S3-9d19dd09.json
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "S3",
"description": "fixed a bug where createPresignedPost could result in a process crash."
}
8 changes: 6 additions & 2 deletions lib/services/s3.js
Expand Up @@ -1079,9 +1079,13 @@ AWS.util.update(AWS.S3.prototype, {
config.getCredentials(function (err) {
if (err) {
callback(err);
} else {
try {
callback(null, finalizePost());
} catch (err) {
callback(err);
}
}

callback(null, finalizePost());
});
} else {
return finalizePost();
Expand Down

0 comments on commit 71d6fa9

Please sign in to comment.