Skip to content

net.connect: behaviour when no arguments are passed #33930

Closed
@rexagod

Description

@rexagod

net.connect() - no args does ECONNREFUSED but should be invalid usage

I think I commented on this, and fixed it in backports, and it was thought
that net.connect() should be same as net.connect({port:undefined}), but I
don't agree, it never makes sense to connect when you don't say what you are
connecting to, it has no use case. also strange that undefined works like no
args were passed, but null is like {port: null} was passed. This all
seems ugly and messy. Check the tests.

For the quote above outlined in #33715 (comment), two solutions come to mind.

  • Throw ERR_MISSING_ARGS when no arguments are passed (as suggested above -- invalid usage).
  • To fix the difference in behavior between port: undefined and port: null, either make port a mandatory field that throws ERR_INVALID_ARGS for anything other than string or numeric values or don't throw ERR_INVALID_ARGS for port: null. This needs more brainstorming.

I'd appreciate a few pointers here to see where this should be going.

cc @sam-github

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussIssues opened for discussions and feedbacks.netIssues and PRs related to the net subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions