Skip to content

https: Agent.createConnection mutates options object #31119

Description

@ronag

createConnection should create a copy instead of mutating the passed options object.

const options = { port: 3000 };
htptpAgent.createConnection('localhost', 2000, options);
assert(options.port, 3000); // fails
assert(options.host, undefined); // fails

Activity

  1. ronag commented on Dec 28, 2019

    @ronag
    MemberAuthor

    Good first issue?

  2. changed the title [-]https: createConnection mutates options object[/-] [+]https: Agent.createConnection mutates options object[/+] on Dec 28, 2019
  3. added
    good first issueIssues that are suitable for first-time contributors.
    httpsIssues and PRs related to the https subsystem.
    on Dec 30, 2019
  4. vighnesh153 commented on Jan 1, 2020

    @vighnesh153
    Contributor

    Hey @ronag , @Trott . I would like to go fix this issue. I have read the CONTRIBUTING.md file. Is there anything else I need to know before proceeding like should I just create a pull request after solving the issue or do I have to do something else as well? This is my first time contributing to an open-source project. Any help would be appreciated.

  5. ronag commented on Jan 1, 2020

    @ronag
    MemberAuthor

    @vighnesh153: Create a PR and follow the instructions. Also please add a test that fails before fix and succeeds after fix.

  6. vighnesh153 commented on Jan 1, 2020

    @vighnesh153
    Contributor

    Alright. I will start working on it right away.

  7. vighnesh153 commented on Jan 1, 2020

    @vighnesh153
    Contributor

    In the lib/_http_agent.js, I can see a line:
    Agent.prototype.createConnection = net.createConnection;
    That leads me to the lib/net.js file. There, I saw

    module.exports = {
    ...,
      createConnection: connect,
    ...
    }
    

    So, from there, I went to connect definition and its comment-doc says that it has 3 forms:

    // There are various forms:
    //
    // connect(options, [cb])
    // connect(port, [host], [cb])
    // connect(path, [cb]);
    

    None of them matches the one that is mentioned in the issue. Am I looking at the correct function?

    Also, I see a test directory and inside it, there are several other directories. One of them being internet. Should I add a new test file in that directory or should I use an existing one?

  8. ronag commented on Jan 1, 2020

    @ronag
    MemberAuthor

    You should be looking for https not http.

    See the test in test/parallel for examples and you should either add a new test there or modify and existing one.

  9. vighnesh153 commented on Jan 1, 2020

    @vighnesh153
    Contributor

    Ok. Got it. I will look into that.

  10. vighnesh153 commented on Jan 1, 2020

    @vighnesh153
    Contributor

    While running the tests, some of the tests pass, but many others throw unhandled errors. I haven't touched the code yet. Am I missing out on something?

    Edit:
    Those were some experimental features. I guess I should ignore those errors.

  11. vighnesh153 commented on Jan 2, 2020

    @vighnesh153
    Contributor

    @ronag This is the PR link. It is a bit messy but I have squashed all commits into one at the end. Please give your feedback on it. #31151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.httpsIssues and PRs related to the https subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions