STS Client doesn't close all asynchronous processes, reported by Jest.
See original GitHub issueConfirm by changing [ ] to [x] below to ensure that it’s a bug:
- I’ve gone through Developer Guide and API reference
- I’ve checked AWS Forums and StackOverflow for answers
- I’ve searched for previous similar issues and didn’t find any solution
Describe the bug
When the AWS STS Client invokes the Metadata API, it doesn’t close all its processes. When invoking STS with Jest on a host that has an AWS identity, Jest complains about the hung processes. The only way around the issue is to use a --forceExit
flag which hides other issues.
Is the issue in the browser/Node.js? Node.js
If on Node.js, are you running this on AWS Lambda? No
Details of the browser/Node.js version v12.22.1
SDK version number
“@aws-sdk/client-sts”: “3.13.1”
To Reproduce (observed behavior)
- clone https://github.com/clcpolevaulter/sts-example to EC2 with Docker installed
- Modify
test/sample.spec.js
to have anaccountNumber
androleName
that the EC2 Instance Profile can assume here - Run
docker run -w /workspace -v $(pwd):/workspace node:12-alpine npm run test
Expected behavior Jest test to exit with a status code of 0.
machine:sts-example bob$ npm run test
> sts-example@1.0.0 test /Users/bob/Developer/sts-example
> npm i && jest --testEnvironment=node --testTimeout=60000
npm WARN sts-example@1.0.0 No repository field.
audited 580 packages in 2.503s
25 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
console.log
<redacted>
at Object.<anonymous> (test/sample.spec.js:10:17)
PASS test/sample.spec.js
STS Example
✓ This will hang in docker... (267 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.876 s, estimated 2 s
Ran all test suites.
console.log
{
AssumedRoleId: 'redacted',
Arn: 'arn:aws:sts::<redacted>:assumed-role/<redacted>/axios'
}
at Object.<anonymous> (test/sample.spec.js:17:17)
Actual behavior Jest test doesn’t exit.
> sts-example@1.0.0 test /workspace
> npm ci && jest --testEnvironment=node --testTimeout=60000
added 580 packages in 7.106s
console.log
<redacted>
at Object.<anonymous> (test/sample.spec.js:10:17)
PASS test/sample.spec.js
STS Example
✓ This will hang in docker... (1092 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.781 s
Ran all test suites.
console.log
{
AssumedRoleId: '<redacted>',
Arn: 'arn:aws:sts::<redacted>:assumed-role/<redacted>/axios'
}
at Object.<anonymous> (test/sample.spec.js:17:17)
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Why doesn't Jest complete the async operation(s) in this Node ...
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper...
Read more >Mocking AWS with Jest (and TypeScript) - DEV Community
Here's how I mock AWS using Jest. Let's start with some code that updates an item in DynamoDB. All code samples are available....
Read more >Ginkgo test suite - GitHub Pages
Ginkgo is a testing framework for Go designed to help you write expressive tests. It is best paired with the Gomega matcher library....
Read more >What is Smoke Testing? Build Verification Tests Explained ...
By design, smoke tests do not cover every permutation and edge case. ... QA Wolf converts your browser actions to Playwright/Jest test code....
Read more >How to Test Asynchronous Code with Jest | Pluralsight
Asynchronous Patterns. There are several patterns for handling async operations in JavaScript; the most used ones are: Callbacks.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m able to reproduce the issue on explicitly running the npm script:
The issue is not reproducible if I replace npm script, with the code inside npm script
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.