question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

STS Client doesn't close all asynchronous processes, reported by Jest.

See original GitHub issue

Confirm by changing [ ] to [x] below to ensure that it’s a bug:

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)

  1. clone https://github.com/clcpolevaulter/sts-example to EC2 with Docker installed
  2. Modify test/sample.spec.js to have an accountNumber and roleName that the EC2 Instance Profile can assume here
  3. 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:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
trivikrcommented, May 18, 2021

@trivikr can you try still leveraging the npm script?

I’m able to reproduce the issue on explicitly running the npm script:

$ sudo docker run -w /workspace -v $(pwd):/workspace node:12-alpine npm run test

The issue is not reproducible if I replace npm script, with the code inside npm script

$ sudo docker run -w /workspace -v $(pwd):/workspace node:12-alpine npm i && node node_modules/.bin/jest --testEnvironment=node --testTimeout=60000
0reactions
github-actions[bot]commented, Jun 2, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found