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

lib: destructuring assignment instead of require whole module #22748

Closed
wants to merge 1 commit into from

Conversation

ZYSzys
Copy link
Member

@ZYSzys ZYSzys commented Sep 7, 2018

Minor refactor: Use destructuring assignment instead of require the whole module.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Sep 7, 2018
Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

LGTM.

Do we want to semver-major this? This no longer allows monkey-patched util._extend to take effect when createSocket is called, for example.

@jasnell
Copy link
Member

jasnell commented Sep 7, 2018

Yes, if this impacts the ability to monkey-patch, then it really should be semver-major and we should make sure we run CITGM.

@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Sep 7, 2018
@addaleax addaleax added needs-ci PRs that need a full CI run. needs-citgm PRs that need a CITGM CI run. labels Sep 14, 2018
@joaocgreis
Copy link
Member

Last CI run was not successful for unrelated reasons (nodejs/build#1495).
Resumed: https://ci.nodejs.org/job/node-test-pull-request/17197/

@addaleax addaleax removed needs-ci PRs that need a full CI run. needs-citgm PRs that need a CITGM CI run. labels Sep 16, 2018
@addaleax
Copy link
Member

@Trott
Copy link
Member

Trott commented Nov 16, 2018

@Trott
Copy link
Member

Trott commented Nov 16, 2018

CITGM results are no longer available so I guess this needs another CITGM run...

@Trott
Copy link
Member

Trott commented Nov 17, 2018

@ZYSzys
Copy link
Member Author

ZYSzys commented Nov 17, 2018

@Trott Ah...Is there something wrong ? I'm willing to fix it.

@Trott
Copy link
Member

Trott commented Nov 17, 2018

@Trott Ah...Is there something wrong ? I'm willing to fix it.

Not necessarily. CI is green. CITGM is red, but it always is and requires a bit of care and/or domain knowledge to interpret. It might be totally fine. @nodejs/citgm

@Trott
Copy link
Member

Trott commented Nov 20, 2018

If CITGM is good, then this is ready to land. @nodejs/citgm https://ci.nodejs.org/job/citgm-smoker/1631/

@antsmartian
Copy link
Contributor

It needs a rebase @ZYSzys

@ZYSzys
Copy link
Member Author

ZYSzys commented Dec 22, 2018

@antsmartian Done:)

@Trott
Copy link
Member

Trott commented Dec 23, 2018

Post-rebase CI: https://ci.nodejs.org/job/node-test-pull-request/19758/ ✔️

@Trott Trott added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-citgm PRs that need a CITGM CI run. labels Dec 23, 2018
@BridgeAR
Copy link
Member

@nodejs/tsc PTAL

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@Trott
Copy link
Member

Trott commented Dec 24, 2018

Is removing the ability to monkey-patch a desirable feature or an incidental side-effect?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

I’d like a review from @nodejs/diagnostics. Is this used by APMs to instrument http?

@Qard
Copy link
Member

Qard commented Dec 24, 2018

async-listener, and therefore most APM vendors which depend on it through continuation-local-storage, patch elsewhere in net and http, so I don't think this would be a problem.

@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 31, 2018
@Flarna
Copy link
Member

Flarna commented Jan 3, 2019

We don't have the need to patch net.createConnection currently so it should be no issue now.

But please be aware that monkey patching is the only entry point for APMs this time as javascript has nothing like JVMTI. Therefore changes like this have the ability to break several APMs - with the risk that there are no workarounds available (marking it as semver-major doesn't add workarounds).

Besides that I find net.createConnection is better readable then just createConnection as it's clear that something from net is used. I would us the shortcuts via destruction only for utility function used frequently in a file. But this is just my personal opinion here.

@Trott
Copy link
Member

Trott commented Jan 4, 2019

Besides that I find net.createConnection is better readable then just createConnection as it's clear that something from net is used.

TBH I find most (but not all) changes to destructuring problematic for exactly that reason. Not enough for me to block them, though.

We don't know that this will break anyone's code but we can't be sure. Unless this is a definite improvement, I would be inclined to not do it for that reason. It's why I asked "Is removing the ability to monkey-patch a desirable feature or an incidental side-effect?" If a feature, great. If a side-effect, let's not do this. Aesthetic/cosmetic changes that might break someone's code seems like a bad trade-off.

/ping @addaleax as I believe she has opinions on this type of thing. (And apologies if I'm wrong about that.)

@addaleax
Copy link
Member

addaleax commented Jan 4, 2019

@Trott I don’t think I have much to add to what you were saying here. 👍

@mcollina
Copy link
Member

mcollina commented Jan 4, 2019

It’s probably a good idea to not do this change at all.

@ZYSzys
Copy link
Member Author

ZYSzys commented Jan 4, 2019

Hey, everyone, thanks all of you for your reviews firstly.

Learn a lot from the discussion, so if It’s not a suitable change, feel free to close this PR.

Thank you sincerely again.👍

@ZYSzys ZYSzys closed this Jan 14, 2019
@ZYSzys ZYSzys deleted the refactor branch March 2, 2019 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem. needs-citgm PRs that need a CITGM CI run. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.