Skip to content

Revise error handling for server start events - #2540

Closed
JasanpreetSidhu wants to merge 2 commits into
expressjs:mainfrom
JasanpreetSidhu:patch-1
Closed

JasanpreetSidhu wants to merge 2 commits into
expressjs:mainfrom
JasanpreetSidhu:patch-1

Conversation

@JasanpreetSidhu

Copy link
Copy Markdown

Callback passed to app.listen() runs only when the server starts successfully and It won't receive an error argument. so, need to attach the error handling code as a listener to the error event using server.on() method

Callback passed to app.listen() runs only when the server starts successfully and It won't receive an error argument.
so, need to attach the error handling code as a listener to the error event using server.on() method

Signed-off-by: Jasan Sidhu <jasanpreetsinghsidhu@gmail.com>
@JasanpreetSidhu
JasanpreetSidhu requested a review from a team as a code owner October 22, 2026 21:17
@netlify

netlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit d15308a
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/6ada8302ce48b16692a47c60
😎 Deploy Preview https://deploy-preview-2540--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@krzysdz

krzysdz commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Callback passed to app.listen() runs only when the server starts successfully and It won't receive an error argument.

Since Express 5 the callback is also called on error. This is mentioned e.g. in the migration guide. The logic which implements it is here and it has been merged in expressjs/express#3216. This behaviour is tested and if for some reason it does not work, please open an issue in the express repo.

@krzysdz krzysdz closed this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants