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

fix(ClientRequest): pass custom agent options in passthrough #701

Merged
merged 5 commits into from
Jan 31, 2025

Conversation

mikicho
Copy link
Contributor

@mikicho mikicho commented Jan 27, 2025

resolves: nock/nock#2828

@mikicho mikicho requested a review from kettanaito January 27, 2025 22:44
})
request.end()

await expect(waitForClientRequest(request)).resolves.not.toThrow()
Copy link
Member

Choose a reason for hiding this comment

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

My only concern is that this test doesn't make it clear what's being asserted. Is the expectation for the request to complete without errors? Did it not do that before? We need to define the expectations here clearer, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point.
If the options are not propagated correctly, the request will fail due to its HTTPS nature, as we did not provide a certificate.

Copy link
Member

Choose a reason for hiding this comment

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

I think I will remove this test. The option forwarding is implies in the normalize* function tests, which you've added.

@kettanaito
Copy link
Member

This looks good! I've pushed little changes and also added this forwarding for HTTP agent as well. I think tests could do a bit better, let me know what you think.


const socket = new MockHttpSocket({
connectionOptions: options,
createConnection: createConnection.bind(
this.customAgent || this,
options,
createConnectionOptions,
Copy link
Member

Choose a reason for hiding this comment

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

We don't really have any direct tests for this. Is this a reason for us to add agents.test.ts and test these things on the unit level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw your merged it, but I'm wondering if we need here a unit test to make sure we merge the options correctly.
I tested the normalize function, but I'm not sure if it's enough

Copy link
Member

Choose a reason for hiding this comment

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

Ideally, we can have a follow up PR that unit-tests the agents. I think that's the right surface to do it. Does this makes sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I opened an issue for this, so we won't forget about this:
#703

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

This looks great 👍 Thanks for fixing it.

@kettanaito kettanaito merged commit bcec579 into main Jan 31, 2025
2 checks passed
@kettanaito kettanaito deleted the Michael/fix-https-agent branch January 31, 2025 15:39
@kettanaito
Copy link
Member

Released: v0.37.6 🎉

This has been released in v0.37.6!

Make sure to always update to the latest version (npm i @mswjs/interceptors@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

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.

[nock@14] Axios custom HTTPS agent is broken
2 participants