Skip to content

Fix async middleware errors #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2025
Merged

Conversation

jkyberneees
Copy link
Collaborator

Summary

  • handle Promise rejections from middleware
  • test async middleware error handling

Testing

  • npm test

https://chatgpt.com/codex/tasks/task_e_688a805bbfa88323a8f845b09662ccca

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds error handling for async middleware by catching Promise rejections and routing them to the error handler, along with a test to verify this functionality.

  • Adds Promise rejection handling for async middleware functions
  • Includes test coverage for async middleware error scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/next.js Adds Promise.catch() handling for both router lookup and regular middleware functions
tests/router-coverage.test.js Adds test case to verify async middleware errors are properly caught and handled
Comments suppressed due to low confidence (1)

tests/router-coverage.test.js:372

  • The parameter 'next' is declared but never used in this middleware function. Consider removing it or using an underscore prefix to indicate it's intentionally unused.
      const middleware = async (req, res, next) => {

@jkyberneees jkyberneees merged commit e07288d into master Jul 31, 2025
5 checks passed
@jkyberneees jkyberneees deleted the codex/find-and-fix-important-bug branch July 31, 2025 17:57
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.

1 participant