Skip to content

Commit 4d5d8df

Browse files
committed
Handle startup error in server listen callback
Breaking change in Express v5 release
2 parents de3cbce + 18a74a9 commit 4d5d8df

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nodeJS/authentication/sessions.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ app.get("/", (req, res) => {
110110
});
111111

112112
const PORT = process.env.PORT || 3000;
113-
app.listen(PORT, () => {
113+
app.listen(PORT, (error) => {
114+
if (error) {
115+
throw error;
116+
}
114117
console.log(`App listening on port ${PORT}!`);
115118
});
116119
```

0 commit comments

Comments
 (0)