Repository: aws/aws-sdk-js (js)

Issue:
getSignedUrl is broken in version 2.382.0
I've gotten the latest version of the SDK - which right now is 2.382.0 - and I'm experiencing an issue with *getSignedUrl*. The method always returns:

https://s3.us-east-2.amazonaws.com/

... no matter what. When I downgrade back to ^2.381.0, I have no problems.

Thanks,
Andrew



Pull request description:
make credentials provider chain resolves synchronously
<!--
Thank you for your pull request. Please provide a description below.
-->
fix #2455 

@srchase 

##### Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [x] `npm run test` passes
- [x] changelog is added, `npm run add-change`


Patch:
diff --git a/.changes/next-release/bugfix-credentials-3d679332.json b/.changes/next-release/bugfix-credentials-3d679332.json
new file mode 100644
index 000000000..1247916b3
--- /dev/null
+++ b/.changes/next-release/bugfix-credentials-3d679332.json
@@ -0,0 +1,5 @@
+{
+  "type": "bugfix",
+  "category": "credentials",
+  "description": "Make CredentialProviderChain coalesce resolvation synchronous"
+}
\ No newline at end of file
diff --git a/lib/credentials/credential_provider_chain.js b/lib/credentials/credential_provider_chain.js
index ff7d4925a..2f50ff771 100644
--- a/lib/credentials/credential_provider_chain.js
+++ b/lib/credentials/credential_provider_chain.js
@@ -108,9 +108,7 @@ AWS.CredentialProviderChain = AWS.util.inherit(AWS.Credentials, {
       function resolveNext(err, creds) {
         if ((!err && creds) || index === providers.length) {
           AWS.util.arrayEach(self.resolveCallbacks, function (callback) {
-            AWS.util.defer(function () {
-              callback(err, creds);
-            });
+            callback(err, creds);
           });
           self.resolveCallbacks.length = 0;
           return;


Test patch:
diff --git a/test/credential_provider_chain.spec.js b/test/credential_provider_chain.spec.js
index 53f954a38..a9ccc6211 100644
--- a/test/credential_provider_chain.spec.js
+++ b/test/credential_provider_chain.spec.js
@@ -53,6 +53,18 @@
             return expect(creds.sessionToken).to.equal('session');
           });
         });
+        it('should be able to resolve credentials synchronously', function() {
+          process.env['AMAZON_ACCESS_KEY_ID'] = 'akid';
+          process.env['AMAZON_SECRET_ACCESS_KEY'] = 'secret';
+          process.env['AMAZON_SESSION_TOKEN'] = 'session';
+          var credentials = null;
+          chain.resolve(function(err, creds) {
+            credentials = creds;
+          });
+          expect(credentials.accessKeyId).to.equal('akid');
+          expect(credentials.secretAccessKey).to.equal('secret');
+          expect(credentials.sessionToken).to.equal('session');
+        });
         it('prefers AWS credentials to AMAZON credentials', function() {
           process.env['AWS_ACCESS_KEY_ID'] = 'akid';
           process.env['AWS_SECRET_ACCESS_KEY'] = 'secret';