From 71d6fa9ad07f42e20eadbad11844301caae1a187 Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Fri, 4 Dec 2020 16:23:04 -0500 Subject: [PATCH] Fix dual-callback case (#3537) 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. --- .changes/next-release/bugfix-S3-9d19dd09.json | 5 +++++ lib/services/s3.js | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changes/next-release/bugfix-S3-9d19dd09.json diff --git a/.changes/next-release/bugfix-S3-9d19dd09.json b/.changes/next-release/bugfix-S3-9d19dd09.json new file mode 100644 index 0000000000..6df9dae1eb --- /dev/null +++ b/.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." +} \ No newline at end of file diff --git a/lib/services/s3.js b/lib/services/s3.js index 345f45ef51..ef2f991be8 100644 --- a/lib/services/s3.js +++ b/lib/services/s3.js @@ -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();