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

#1836 fixes expected Node behaviour for http.get #1853

Closed
wants to merge 3 commits into from

Conversation

kennethaasan
Copy link

@kennethaasan kennethaasan commented Jan 10, 2020

Fixes #1836

@mastermatt @paulmelnikow, sorry but I had to make a new PR because I fucked up git when doing a rebase. Would be great if you could release this ASAP so that we can fix newrelic/node-newrelic#316

@kennethaasan
Copy link
Author

@paulmelnikow, do you have any time to review this PR soon?

Thanks, Kenneth

@jrnelson90
Copy link

jrnelson90 commented Feb 4, 2020

Is there any repo manager that can please review this for merging? This issue is bedrock for a hierarchy of issues blocking progress for me at work right now.

@element6
Copy link

element6 commented Feb 4, 2020

I am on the same boat, because newrelic depends on this.

@paulmelnikow
Copy link
Member

Sorry, I’ve been really swamped. I’ll try to take a look at this today.

@@ -512,3 +512,30 @@ test('testing timers are deleted correctly', t => {
t.end()
})
})

test('correct node behavior', t => {
Copy link
Member

Choose a reason for hiding this comment

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

Could this test title capture the stated goal?

This is from the original PR:

The test makes sure http.request is not called when using http.get.

… on a mocked request? Is that it?

Nock has accumulated so much unusual code over the years to work around other libraries quirks, and it’s important that we can document why things are done the way they are. Same goes for a test. You’ll find a lot of tests like “filteringScope works” but it’s not as helpful in the future as saying the behavior that is wanted.

Copy link
Member

Choose a reason for hiding this comment

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

Having dug into this a little more, I think this is not the right test. I think what we want to test is that the overridden / original http.request() is invoked only once by http.get(), instead of twice. That's the stated bug of #1836.

I'm going to dig in a bit and see if I can express that in a new test.

Copy link
Author

Choose a reason for hiding this comment

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

I might have expressed myself a bit poorly in #1836. The main problem is that the native node behavior is not calling req.request when req.get is called. Nock does that in common.js. When using nock together with another library like newrelic that also overwrites these functions, you get a wrong call.

Copy link
Author

Choose a reason for hiding this comment

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

This test checks that you don't call req.request when req.get is called, which is the native node behavior. There is not really anything else to test here in my opinion. I'll rename the test to what you suggested.

Copy link
Member

Choose a reason for hiding this comment

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

Hey, thanks, would appreciate your help to clarify at #1836 (comment).

@paulmelnikow
Copy link
Member

I realize this has a high ecosystem impact and I'd like to get this merged and released in the next day or so. I need some clarification on what the bug's behavior is so I can write a regression test that expresses it clearly. If folks following this thread understand what's happening in New Relic, I'd appreciate your comments in #1836.

@kennethaasan
Copy link
Author

Closing this PR in favor of #1868

@nockbot
Copy link
Collaborator

nockbot commented Feb 10, 2020

🎉 This issue has been resolved in version 11.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kennethaasan kennethaasan deleted the node-http-2 branch February 10, 2020 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breaking expected Node behaviour for http.get Support http/https APIs for node >= 10
6 participants