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

New Server.listen(options[, callback]) method is too picky about port being a js number #1111

Closed
brycebaril opened this issue Mar 10, 2015 · 1 comment
Labels
confirmed-bug Issues with confirmed bugs. http Issues or PRs related to the http subsystem.

Comments

@brycebaril
Copy link
Contributor

Really like this new new listen function, but I've found it's pickier than the others about port being a js number vs a string number, and the error is unclear (uses poor stringification of the object):

// Old .listen(port[, host][, callback])
http.createServer(function (req, res) {
  res.end("\n")
}).listen("8005")

Works fine, converting "8005" to 8005.

While:

// New .listen(options[, callback])
http.createServer(function (req, res) {
  res.end("\n")
}).listen({port: "8005"})

Throws:

Error: Invalid listen argument: [object Object]
    at Server.listen (net.js:1278:15)
    at repl:1:56
    at REPLServer.defaultEval (repl.js:116:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:269:12)
    at emitOne (events.js:77:13)
    at REPLServer.emit (events.js:166:7)
    at REPLServer.Interface._onLine (readline.js:195:10)
    at REPLServer.Interface._line (readline.js:534:8)
@mscdex mscdex added confirmed-bug Issues with confirmed bugs. http Issues or PRs related to the http subsystem. labels Mar 10, 2015
bnoordhuis added a commit to bnoordhuis/io.js that referenced this issue Mar 10, 2015
net.connect() accepts `{ port: "1234" }` (i.e. a string) as of commit
9d2b89d ("net: allow port 0 in connect()") but net.Server#listen()
did not, creating a minor inconsistency.  This commit rectifies that.

Fixes: nodejs#1111
PR-URL: nodejs#1116
Reviewed-By: Colin Ihrig <[email protected]>
@bnoordhuis
Copy link
Member

Fixed by 480b482.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants