René's URL Explorer Experiment


Title: Promisify server.listen · Issue #21482 · nodejs/node · GitHub

Open Graph Title: Promisify server.listen · Issue #21482 · nodejs/node

X Title: Promisify server.listen · Issue #21482 · nodejs/node

Description: Problem: const server = app.listen(); console.log(`Server listening on: ${server.address().port}`) can fail, as the server is created asynchronously and using the callback is not always practical/flexible Proposal either server.listenPro...

Open Graph Description: Problem: const server = app.listen(); console.log(`Server listening on: ${server.address().port}`) can fail, as the server is created asynchronously and using the callback is not always practical/f...

X Description: Problem: const server = app.listen(); console.log(`Server listening on: ${server.address().port}`) can fail, as the server is created asynchronously and using the callback is not always practical/f...

Opengraph URL: https://github.com/nodejs/node/issues/21482

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Promisify server.listen","articleBody":"### Problem:\r\n```js\r\nconst server = app.listen();\r\nconsole.log(`Server listening on: ${server.address().port}`)\r\n```\r\ncan fail, as the server is created asynchronously and using the callback is not always practical/flexible\r\n\r\n### Proposal\r\neither `server.listenPromise(port)`, or even better, have `server.listen(port)` return a Promise if no callback is provided\r\n\r\n### Example\r\n```js\r\n\r\n// .... \r\n\r\nconst start = async () => {\r\n    await config.load();\r\n    await DB.connect(dbOptions);\r\n    router(app);\r\n    app.use((err, req, res, next) => { // error handler\r\n        // ...\r\n    });\r\n\r\n    const server = http.createServer(app);\r\n    // proposal:\r\n    return server.listen(process.env.PORT || 3000); // if .listen would be a promise resolving to server\r\n    // or await server.listen(...); return server; else\r\n\r\n    // currently I have to do:\r\n    // return new Promise((res, rej) => server.listen(process.env.PORT || 3000, err => err ? rej(err) : res()));\r\n\r\n    // or using express's app.listen, which wraps createServer and listen:\r\n    // return new Promise((res, rej) => app.listen(process.env.PORT || 3000, function (err) {\r\n    //      if (err) return rej(err);\r\n    //      res(this) // this is node's http Server\r\n    // }));\r\n\r\n    // using util.promisify doesn't look much better:\r\n    // return promisify(server.listen).bind(server)(process.env.PORT || 3000);\r\n    // or\r\n    // return promisify(cb => server.listen(process.env.PORT || 3000, cb))();\r\n};\r\n```\r\n\r\nthen using it somewhere else:\r\n```js\r\nstart()\r\n        .then(server => console.log(`Server listening on: ${server.address().port}`))\r\n        .catch(err => {\r\n           // ...\r\n        });\r\n```\r\n\r\nEdit: 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\r\n\r\nEdit2: the discussion in expressjs/express#3675 has interesting details","author":{"url":"https://github.com/caub","@type":"Person","name":"caub"},"datePublished":"2018-06-23T07:11:43Z","url":"https://github.com/nodejs/node/issues/21482"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b1f4a55a-0238-83b0-d0e7-b268daf55107
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCB68:6780E:564907:7070DD:6AED28E6
html-safe-nonced2b31040577580fbe65c4af7ef1bc3068baa47b812679b35325bf9fc2ca8ce9e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjY4OjY3ODBFOjU2NDkwNzo3MDcwREQ6NkFFRDI4RTYiLCJ2aXNpdG9yX2lkIjoiMTAxMDI3MjM0OTU3NjgzMzI1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9249f2120dc820e2c09002f621d1745eca9dc8e705ccea36a12614820a358583
hovercard-subject-tagissue:335076411
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/21482/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7592c885cf4594fe1d89a8cc82e4b6ca781d9ac6d540313ba157e5d4e4f68d25/nodejs/node/issues/21482
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7592c885cf4594fe1d89a8cc82e4b6ca781d9ac6d540313ba157e5d4e4f68d25/nodejs/node/issues/21482
og:image:altProblem: const server = app.listen(); console.log(`Server listening on: ${server.address().port}`) can fail, as the server is created asynchronously and using the callback is not always practical/f...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecaub
hostnamegithub.com
expected-hostnamegithub.com
None9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release98b41fa4b5635ceb45a4c54320fced73817ff290
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/21482#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F21482
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F21482
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/21482
Reloadhttps://github.com/nodejs/node/issues/21482
Reloadhttps://github.com/nodejs/node/issues/21482
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues657 (657)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/21482
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/21482
Promisify server.listenhttps://github.com/nodejs/node/issues/21482#top
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
netIssues and PRs related to the net subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22net%22
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
https://github.com/caub
caubhttps://github.com/caub
on Jun 23, 2018https://github.com/nodejs/node/issues/21482#issue-335076411
https://github.com/expressjs/express/blob/master/lib/application.js#L616-L619https://github.com/expressjs/express/blob/master/lib/application.js#L616-L619
expressjs/express#3675https://github.com/expressjs/express/pull/3675
Nexthttps://github.com/nodejs/node/issues/21482?timeline_page=1
apapirovskihttps://github.com/apapirovski
netIssues and PRs related to the net subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22net%22
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
on Jun 24, 2018https://github.com/nodejs/node/issues/21482#event-1697766001
https://github.com/jsmrcaga
jsmrcagahttps://github.com/jsmrcaga
on Aug 31, 2018https://github.com/nodejs/node/issues/21482#issuecomment-417806301
herehttps://github.com/nodejs/node/blob/master/lib/net.js#L1415
https://github.com/jsmrcaga
jsmrcagahttps://github.com/jsmrcaga
on Sep 1, 2018https://github.com/nodejs/node/issues/21482#issuecomment-417866297
https://github.com/caub
caubhttps://github.com/caub
on Sep 13, 2018https://github.com/nodejs/node/issues/21482#issuecomment-420952916
@jsmrcagahttps://github.com/jsmrcaga
@bmeckhttps://github.com/bmeck
https://github.com/shellscape
shellscapehttps://github.com/shellscape
on Oct 9, 2018https://github.com/nodejs/node/issues/21482#issuecomment-428038414
@caubhttps://github.com/caub
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Oct 9, 2018https://github.com/nodejs/node/issues/21482#issuecomment-428038924
@shellscapehttps://github.com/shellscape
https://github.com/shellscape
shellscapehttps://github.com/shellscape
on Oct 9, 2018https://github.com/nodejs/node/issues/21482#issuecomment-428039570
@addaleaxhttps://github.com/addaleax
https://github.com/MartinMuzatko
MartinMuzatkohttps://github.com/MartinMuzatko
on Feb 15, 2019https://github.com/nodejs/node/issues/21482#issuecomment-463948900
@caubhttps://github.com/caub
https://github.com/axkibe
axkibehttps://github.com/axkibe
on Apr 2, 2019https://github.com/nodejs/node/issues/21482#issuecomment-479114720
@MartinMuzatkohttps://github.com/MartinMuzatko
https://github.com/strarsis
strarsishttps://github.com/strarsis
on Aug 30, 2019https://github.com/nodejs/node/issues/21482#issuecomment-526716006
@axkibehttps://github.com/axkibe
https://github.com/stavalfi
stavalfihttps://github.com/stavalfi
on Dec 10, 2019https://github.com/nodejs/node/issues/21482#issuecomment-564134626
@jsmrcagahttps://github.com/jsmrcaga
@bmeckhttps://github.com/bmeck
https://github.com/webarnes
webarneshttps://github.com/webarnes
on Jan 12, 2020https://github.com/nodejs/node/issues/21482#issuecomment-573468240
https://github.com/ftzi
ftzihttps://github.com/ftzi
on May 8, 2020https://github.com/nodejs/node/issues/21482#issuecomment-625775375
@jsmrcagahttps://github.com/jsmrcaga
@bmeckhttps://github.com/bmeck
https://github.com/jsmrcaga
jsmrcagahttps://github.com/jsmrcaga
on May 8, 2020https://github.com/nodejs/node/issues/21482#issuecomment-625790353
Node 14.2https://nodejs.org/api/http.html
express v4https://expressjs.com/en/4x/api.html#app.onmount
https://github.com/tompahoward
tompahowardhttps://github.com/tompahoward
on Feb 16, 2023https://github.com/nodejs/node/issues/21482#issuecomment-1432427129
@silverwindhttps://github.com/silverwind
'listening'https://nodejs.org/api/net.html#event-listening
https://nodejs.org/api/net.html#serverlistenhttps://nodejs.org/api/net.html#serverlisten
'error'https://nodejs.org/api/net.html#event-error
https://github.com/jrichardsz
jrichardszhttps://github.com/jrichardsz
on Dec 12, 2023https://github.com/nodejs/node/issues/21482#issuecomment-1852902808
https://github.com/mosoriorian
mosoriorianhttps://github.com/mosoriorian
on Jan 25, 2024https://github.com/nodejs/node/issues/21482#issuecomment-1910463549
https://github.com/mpicardvolvo
mpicardvolvohttps://github.com/mpicardvolvo
on Feb 28, 2024https://github.com/nodejs/node/issues/21482#issuecomment-1968736247
https://github.com/drmaquino
drmaquinohttps://github.com/drmaquino
on Feb 28, 2024https://github.com/nodejs/node/issues/21482#issuecomment-1969591666
https://github.com/axkibe
axkibehttps://github.com/axkibe
on Feb 29, 2024https://github.com/nodejs/node/issues/21482#issuecomment-1970661857
avivkellerhttps://github.com/avivkeller
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Jun 26, 2024https://github.com/nodejs/node/issues/21482
Ethan-Arrowoodhttps://github.com/Ethan-Arrowood
on Jul 14, 2026https://github.com/nodejs/node/issues/21482#event-27970658272
net: add experimental net/promises APIhttps://github.com/Ethan-Arrowood/node/commit/ab5b8e9e50baf109dee3f298f581bed9f51007fb
ab5b8e9https://github.com/Ethan-Arrowood/node/commit/ab5b8e9e50baf109dee3f298f581bed9f51007fb
net: tie listen() signal to server lifetime, async-iterable Serverhttps://github.com/Ethan-Arrowood/node/commit/84ae4220da54bb8710973be6156f48b0101b5679
84ae422https://github.com/Ethan-Arrowood/node/commit/84ae4220da54bb8710973be6156f48b0101b5679
net: use throwIfAborted and improve server iteration examplehttps://github.com/Ethan-Arrowood/node/commit/25fa21a6bf2811adefb6103e5d9cd5f3bb4f8123
25fa21ahttps://github.com/Ethan-Arrowood/node/commit/25fa21a6bf2811adefb6103e5d9cd5f3bb4f8123
nodejs-github-bothttps://github.com/nodejs-github-bot
on Jul 28, 2026https://github.com/nodejs/node/issues/21482#event-28619441937
net: add experimental net/promises APIhttps://github.com/nodejs/node/commit/6d8baeabb0d9b2a0e1e27174e65d0cde97698f46
6d8baeahttps://github.com/nodejs/node/commit/6d8baeabb0d9b2a0e1e27174e65d0cde97698f46
aduh95https://github.com/aduh95
on Aug 3, 2026https://github.com/nodejs/node/issues/21482#event-28901686426
net: add experimental net/promises APIhttps://github.com/nodejs/node/commit/3abb9a382e5bf6914b80209824808d42f6190970
3abb9a3https://github.com/nodejs/node/commit/3abb9a382e5bf6914b80209824808d42f6190970
net: add experimental net/promises APIhttps://github.com/nodejs/node/commit/b6e7935aca55fdf107a60786d119a24c3330be5b
b6e7935https://github.com/nodejs/node/commit/b6e7935aca55fdf107a60786d119a24c3330be5b
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/21482
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/21482
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
netIssues and PRs related to the net subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22net%22
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.