-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to? Catch missing credentials errors #242
Comments
I can't seem to reproduce your behavior with the exception being thrown out of the call. I run the following: delete process.env.AWS_ACCESS_KEY_ID;
delete process.env.AWS_SECRET_ACCESS_KEY;
var AWS = require('aws-sdk');
console.log(AWS.VERSION);
var s3 = new AWS.S3();
s3.listObjects({ Bucket: "my-bucket" }, function(err, objects){
console.log(err, objects);
}); And I get this:
Note that it is being printed as part of the callback. |
Okay, so, it turns out that my web framework (Hapi) creates a Domain for the request/response lifecycle, this represents that: https://gist.github.com/miksago/115c337327f64a3f086f Essentially, the error gets printed twice. |
It looks like we are jumping to the uncaughtError state of our request lifecycle when an error pops up in the complete event. I will look into this. |
Thanks for reporting this issue. |
@lsegal could you let me know when you ship a new release? |
I experience the same problem. I'm using aws-sdk 2.0.0-rc.17. I know the error is due to missing credentials, and want to make sure it's caught if it ever happens. I found that a TimeoutError would be returned in callback-style in the first 2-3 times this happens, but in around the 3rd time, a CredentialsError is thrown that will crash the process.
The error:
|
@danie11am I would recommend upgrading to the latest version of the SDK (rc20) as error handling has changed slightly to not throw these exceptions. |
I just tried rc20, it no longer has this problem. Error is returned via callback even after many tries. Thanks @lsegal! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
I'm getting the following error when from the following code:
I know that this is because I've not supplied credentials (I'm using the environment provider), but I wish to catch this error and be able to show something more sensible back to the developer, and to also terminate the request which ends up triggering the
listObjects
call.Seems to not come back via the standard (err, data) function signature.
Any ideas?
The text was updated successfully, but these errors were encountered: