Skip to content
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

test(credential-provider-imds): abort nock pending requests in timeout check #4837

Merged
merged 2 commits into from Jun 13, 2023

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Jun 13, 2023

Issue

Refs: #4827

Description

Aborts nock pending requests when testing timeout

Testing

Before

$ yarn test --detectOpenHandles
...
Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  Timeout

       8 | export function httpRequest(options: RequestOptions): Promise<Buffer> {
       9 |   return new Promise((resolve, reject) => {
    > 10 |     const req = request({
         |                        ^
      11 |       method: "GET",
      12 |       ...options,
      13 |       // Node.js http module doesn't accept hostname with square brackets

      at new InterceptedRequestRouter (../../node_modules/nock/lib/intercepted_request_router.js:78:13)
      at new OverriddenClientRequest (../../node_modules/nock/lib/intercept.js:286:25)
      at ../../node_modules/nock/lib/intercept.js:423:14
      at module.request (../../node_modules/nock/lib/common.js:96:14)
      at src/remoteProvider/httpRequest.ts:10:24
      at httpRequest (src/remoteProvider/httpRequest.ts:9:10)
      at src/remoteProvider/httpRequest.spec.ts:112:29
      at src/remoteProvider/httpRequest.spec.ts:31:71
      at Object.<anonymous>.__awaiter (src/remoteProvider/httpRequest.spec.ts:27:12)
      at Object.<anonymous> (src/remoteProvider/httpRequest.spec.ts:105:28)

After

$ yarn test --detectOpenHandles
...
Test Suites: 11 passed, 11 total
Tests:       75 passed, 75 total
Snapshots:   0 total
Time:        4.455 s
Ran all test suites.
✨  Done in 5.08s.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr changed the title test(credential-provider-imds): wait for nock to send response test(credential-provider-imds): abort nock pending requests when testing timeout Jun 13, 2023
@trivikr trivikr marked this pull request as ready for review June 13, 2023 21:17
@trivikr trivikr requested a review from a team as a code owner June 13, 2023 21:17
@trivikr trivikr changed the title test(credential-provider-imds): abort nock pending requests when testing timeout test(credential-provider-imds): abort nock pending requests in timeout check Jun 13, 2023
@trivikr trivikr merged commit 1cb4847 into main Jun 13, 2023
3 checks passed
@trivikr trivikr deleted the test-credential-provider-imds-open-handles branch June 13, 2023 23:49
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants