Skip to content
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

fix(medusa): Update wrapHandler so it also passes errors in non-async route handlers to the errorHandler middleware #5597

Merged
merged 11 commits into from
Nov 15, 2023

Conversation

kasperkristensen
Copy link
Contributor

@kasperkristensen kasperkristensen commented Nov 10, 2023

What

  • Update wrapHandler so it also passes errors in non-async route handlers to the errorHandler middleware.

Why

  • Currenty wrapHandler only works for async route handlers, but much of our documentation examples on API Routes uses non-async route handlers. While a route handler will be async in 99.99% of all real life cases, this change ensures that our default error handling will work correctly if a user is still testing out different examples from our documentation, etc.

@kasperkristensen kasperkristensen requested a review from a team as a code owner November 10, 2023 08:45
Copy link

changeset-bot bot commented Nov 10, 2023

🦋 Changeset detected

Latest commit: 3dcad7a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@medusajs/medusa Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Nov 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Visit Preview Nov 15, 2023 5:58pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Nov 15, 2023 5:58pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Nov 15, 2023 5:58pm

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

nice catch!

packages/medusa/src/api/middlewares/await-middleware.ts Outdated Show resolved Hide resolved
@olivermrbl
Copy link
Contributor

@adrien2p are you OK with this approach?

@olivermrbl
Copy link
Contributor

Merging as agreed upon in comments.

@olivermrbl olivermrbl merged commit 2947f57 into develop Nov 15, 2023
15 checks passed
@olivermrbl olivermrbl deleted the fix/await-middleware-handle-sync-fn branch November 15, 2023 18:41
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.

3 participants