-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
Promisify server.listen #21482
Copy link
Copy link
Closed
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
Activity
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Problem:
can fail, as the server is created asynchronously and using the callback is not always practical/flexible
Proposal
either
server.listenPromise(port), or even better, haveserver.listen(port)return a Promise if no callback is providedExample
then using it somewhere else:
Edit: I'll try to submit this request to express, and have a similar promise method near https://github.com/expressjs/express/blob/master/lib/application.js#L616-L619
Edit2: the discussion in expressjs/express#3675 has interesting details