Skip to content

feat: change code to use url.URL instead of url.parse #1340

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

Merged
merged 4 commits into from
Sep 16, 2019

Conversation

yuxizhe
Copy link
Contributor

@yuxizhe yuxizhe commented Sep 11, 2019

close #1254

Checklist

  • Implement code

Qard
Qard previously approved these changes Sep 11, 2019
@Qard
Copy link
Contributor

Qard commented Sep 11, 2019

jenkins run the tests please

@Qard
Copy link
Contributor

Qard commented Sep 11, 2019

Marked as breaking change as the URL class does not exist yet in Node.js 6 so we have to finish dropping v6 first.

Copy link
Contributor

@watson watson left a comment

Choose a reason for hiding this comment

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

Great work!

I just left a few review comments and then it should be good to go.

Another recommendation that I would make would be to move the logic of checking if url.URL is available into a utility function which you can just call instead, so:

url.URL ? new url.URL(urlStr, 'relative:///') : url.parse(urlStr)

Would be turned into

parseUrl(urlStr)

And parseUrl could then just be a function on lib/parsers.js:

exports.parseUrl = function (urlStr) {
  return url.URL ? new url.URL(urlStr, 'relative:///') : url.parse(urlStr)
}

@yuxizhe
Copy link
Contributor Author

yuxizhe commented Sep 13, 2019

@watson All fixed, Thanks for your advice 👍

Qard
Qard previously approved these changes Sep 13, 2019
@Qard
Copy link
Contributor

Qard commented Sep 13, 2019

jenkins run the tests please

@Qard
Copy link
Contributor

Qard commented Sep 13, 2019

jenkins run the tests please

@Qard
Copy link
Contributor

Qard commented Sep 13, 2019

So with this using both url.Url and url.parse(...), are we targeting landing this in 2.x as a not a breaking change? If so, it appears to be failing in Node.js 6.x and we should figure out why. If we want to just do this as a breaking change in 3.x, it should be fine as-is.

@watson
Copy link
Contributor

watson commented Sep 15, 2019

I think it's easiest to target 2.x now and then we can just remove the url.parse fallback once we're in 3.x. That way we get the best of both worlds with almost no effort

@watson
Copy link
Contributor

watson commented Sep 15, 2019

I'll just look into the failing Node.js 6 test...

@yuxizhe
Copy link
Contributor Author

yuxizhe commented Sep 16, 2019

I'll just look into the failing Node.js 6 test...

Very strange. It passed travis-ci node 6 tests, but failed in apm-ci node 6. I can't reproduce that error on my computer with node 6.x.

@watson
Copy link
Contributor

watson commented Sep 16, 2019

I've seen this specific test failure on Jenkins a few times in other PRs lately. So I think the Node.js 6 tests are just flaky when running on Jenkins. I'll go ahead and run the tests one more time to see if it goes away.

@watson
Copy link
Contributor

watson commented Sep 16, 2019

jenkins run the tests please

@watson
Copy link
Contributor

watson commented Sep 16, 2019

This time around the

@watson watson closed this Sep 16, 2019
@watson watson reopened this Sep 16, 2019
@watson
Copy link
Contributor

watson commented Sep 16, 2019

Ups, I pressed the wrong button 🤦‍♂

Was about to write that this time around the Node.js 6 tests passed just fine 😅

@watson
Copy link
Contributor

watson commented Sep 16, 2019

I've created another issue with the Node.js 6 failures on Jenkins: #1350

@watson watson merged commit dd60b12 into elastic:master Sep 16, 2019
@watson
Copy link
Contributor

watson commented Sep 16, 2019

Thanks a lot for helping us fix this one @yuxizhe 💯 It'll be part of the next release 😃

@yuxizhe
Copy link
Contributor Author

yuxizhe commented Sep 16, 2019

Thanks a lot for helping us fix this one @yuxizhe 💯 It'll be part of the next release 😃

My pleasure : )

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.

Change code to use url.URL instead of url.parse
3 participants