Skip to content

undefined port should trigger a RangeError when launching a server #14205

Closed
@paulbrie

Description

@paulbrie
  • Version: 7.9.0
  • Platform: Darwin MacBook-Air-de-paul-7.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
  • Subsystem: ?

Hi guys,

On my version/platform it is possible to launch a server with an undefined port. This is misleading given that there's no error message and you believe the server is working but in fact it does not listen at all. On other versions it throws a RangeError.

A complete history can be found here: expressjs/express#3364 but Doug (https://github.com/dougwilson) gave me this one liner which makes it easy to test:

Thanks,
Paul

node -pe 'require("http").createServer(function(){}).listen(undefined, function(){})'
Server {
  domain: null,
  _events:
   { request: [Function],
     connection: [Function: connectionListener],
     listening: { [Function: bound onceWrapper] listener: [Function] } },
  _eventsCount: 3,
  _maxListeners: undefined,
  _connections: 0,
  _handle:
   TCP {
     bytesRead: 0,
     _externalStream: {},
     fd: 11,
     reading: false,
     owner: [Circular],
     onread: null,
     onconnection: [Function: onconnection],
     writeQueueSize: 0 },
  _usingSlaves: false,
  _slaves: [],
  _unref: false,
  allowHalfOpen: true,
  pauseOnConnect: false,
  httpAllowHalfOpen: false,
  timeout: 120000,
  _pendingResponseData: 0,
  maxHeadersCount: null,
  _connectionKey: '6::::0' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.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