Skip to content

Conversation

@danwkennedy
Copy link
Contributor

@danwkennedy danwkennedy commented Jan 30, 2026

Description

I noticed this while I was upgrading the packages. This should silence a warning from Jest.

@danwkennedy danwkennedy requested a review from a team as a code owner January 30, 2026 13:44
Copilot AI review requested due to automatic review settings January 30, 2026 13:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates a couple of test cases to ensure HTTP response sockets are closed, addressing a Jest warning about resources outliving their tests.

Changes:

  • Close the response stream in an http-client HEAD request test to prevent lingering sockets.
  • Drain/close the response stream in a core OIDC HTTP GET test to avoid open-handle warnings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/http-client/tests/basics.test.ts Ensures the HEAD response stream is closed so the socket doesn’t outlive the test.
packages/core/tests/core.test.ts Drains/closes the OIDC endpoint response to prevent Jest open-handle warnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

)
expect(res.message.statusCode).toBe(200)
// Consume the response to close the socket
res.message.destroy()
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says the response is being consumed, but res.message.destroy() actually aborts the stream. For a HEAD request you can drain/consume cleanly by awaiting res.readBody() (it should resolve to an empty string) and avoid calling destroy(), which keeps the intent clear and matches the pattern used in other tests in this file.

Suggested change
res.message.destroy()
await res.readBody()

Copilot uses AI. Check for mistakes.
expect(res.message.statusCode).toBe(200)
// Consume the response to close the socket
await res.readBody()
res.message.destroy()
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await res.readBody() should already fully drain the response and allow the underlying socket to close; calling res.message.destroy() afterwards is redundant and makes the intent a bit unclear. Consider dropping the destroy() (or updating the comment if you intentionally want to abort instead of just consuming).

Suggested change
res.message.destroy()

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants