Skip to content

Upgrade to express.js 5#39

Merged
danieldaquino merged 1 commit into
damus-io:masterfrom
danieldaquino:express-upgrade
May 20, 2026
Merged

Upgrade to express.js 5#39
danieldaquino merged 1 commit into
damus-io:masterfrom
danieldaquino:express-upgrade

Conversation

@danieldaquino
Copy link
Copy Markdown
Collaborator

@danieldaquino danieldaquino commented May 20, 2026

This upgrades the express.js library to version 5, which includes automatic route-based error handling for async operations.

See https://expressjs.com/en/guide/error-handling/#:~:text=Starting%20with%20Express%205%2C%20route%20handlers%20and%20middleware%20that%20return%20a%20Promise%20will%20call%20next(value)%20automatically%20when%20they%20reject%20or%20throw%20an%20error.

This should improve error handling and prevent thrown errors from taking down the entire server process.

To help ensure no deprecated APIs are in use, the command npx codemod@1.7.11 @expressjs/v5-migration-recipe was run as recommended by https://expressjs.com/en/guide/migrating-5/, with no necessary code changes.

Testing

  • Ran npx codemod@1.7.11 @expressjs/v5-migration-recipe from https://expressjs.com/en/guide/migrating-5/ to ensure any API changes are addressed.
  • Ran entire test suite, with all tests passing
  • Added new test, ensured it passes in the new version and confirmed it fails in the previous version.

Summary by CodeRabbit

  • Chores

    • Upgraded Express framework dependency from version 4.18.2 to version 5.2.1, incorporating the latest enhancements, security patches, and stability improvements.
  • Tests

    • Added comprehensive test coverage to verify application resilience when asynchronous route handlers encounter errors, ensuring proper error handling through middleware error handlers and confirming the application continues to serve subsequent requests seamlessly.

Review Change Stack

This upgrades the express.js library to version 5, which includes
automatic route-based error handling for async operations.

See https://expressjs.com/en/guide/error-handling/#:~:text=Starting%20with%20Express%205%2C%20route%20handlers%20and%20middleware%20that%20return%20a%20Promise%20will%20call%20next(value)%20automatically%20when%20they%20reject%20or%20throw%20an%20error.

This should improve error handling and prevent thrown errors from taking
down the entire server process.

To help ensure no deprecated APIs are in use, the command `npx
codemod@1.7.11 @expressjs/v5-migration-recipe` was run as recommended by https://expressjs.com/en/guide/migrating-5/
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

📝 Walkthrough

Walkthrough

The PR upgrades Express from v4.18.2 to v5.2.1 and adds a test case validating that async route handler errors are properly handled by error middleware without crashing the server, allowing subsequent requests to be processed successfully.

Changes

Error Resilience

Layer / File(s) Summary
Express dependency upgrade
package.json
Express is bumped to v5.2.1, updating the runtime server framework to a new major version.
Async error recovery test
test/router_config.test.js
New test confirms that a thrown error in an async route handler is caught by error middleware (returning HTTP 500), and the server continues handling subsequent requests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 An express update hops along,
Version five brings error songs—
Routes that throw won't crash the day,
Middleware catches, errors stay!
Server bounces, thrives once more. 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Upgrade to express.js 5' is clear and specific, directly summarizing the main change of upgrading the Express dependency version.
Linked Issues check ✅ Passed The upgrade to Express 5 addresses the linked issue #5 by implementing automatic error handling for async route handlers that reject/throw, preventing unhandled exceptions from crashing the API process.
Out of Scope Changes check ✅ Passed All changes are in scope: the package.json upgrade to Express 5 and the test addition validating error handling behavior are both directly related to the PR objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@danieldaquino
Copy link
Copy Markdown
Collaborator Author

CC @jb55

@danieldaquino danieldaquino merged commit 4bb1035 into damus-io:master May 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant