aws-sdk-js: Request hangs on missing credentials
- I’ve gone though Developer Guide and API reference
- I’ve checked AWS Forums and StackOverflow for answers
When I attempt to run request without an AWS credentials it just hangs infinitely.
I’d expect it to crash immediately with Missing credentials
error.
Why it’s not the case?
e.g. following will just hang if run without any AWS creds setup:
const { Lambda } = require('aws-sdk');
const lambda = new Lambda();
lambda
.invoke({ FunctionName: 'foo' })
.promise()
.then(
data => console.log('Success', data),
error => console.log('Error', data)
);
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 28 (13 by maintainers)
@medikoo have you tried
connectTimeout
? That worked for me last time I checked this issueEDIT:
connectTimeout
, notconnectionTimeout
@ajredniwja
Regarding your statement:
I’m not sure if anyone has mentioned/encountered this, but when I run the SDK with invalid credentials a few times, it occasionally does error with
MissingCredentials
, but usually hangs. This definitely would classify as a bug to me, if the behaviour is inconsistent. It should either hang consistently or throw an error consistently.@pauloprestes I tried this on node v13.11 and SDK versions v2.655.0 and v2.656.0 but it still hangs
Code to replicate
How can you overwrite the timeout? I tried:
But it’s still taking ~2.5min to fail
Hey @ajredniwja I’ve seen this behavior happening on lambdas with high volume of invocations, like 1 on 1k invocations, maybe even less. Generally it is easy solved by adding a timeout and retries.
Thanks @ajredniwja I’ll try to look into that
aws-sdk-go
checks if the timeout is set to 0 for the ec2metada and overrides it to 1 second, to solve this issue, maybe we could do the same here? https://github.com/aws/aws-sdk-go/blob/0c96ad536ae45eb23a2b5ed2b4ef9a840eec6f6e/aws/ec2metadata/service.go#L76on
aws-sdk-js
, it is always set to 0. https://github.com/aws/aws-sdk-js/blob/2d1be139f5d95b4846e5c99a474f08a7c093c440/lib/metadata_service.js#L38Encountered this error with a typo in my access credential properties, cost a lot of time trying to work out the issue because the SDK never reported an error.