+
Skip to content

Conversation

kricsleo
Copy link
Member

resolves #1172

This PR enables middleware to pass through the response from other middlewares or handler without enforcing an explicit return next().

This improves DX, especially when the user doesn't care about the response and is likely to forget to return after calling next().

Before:

app.use(async (event, next) => {
  // before...
  const result = await next()
  // after...

  // ↓ this is likely to be forgotton.
  return result
})

After:

app.use(async (event, next) => {
  // before...
  await next()
  // after...

  // no needs to return
})

@kricsleo kricsleo requested a review from pi0 as a code owner July 27, 2025 10:52
Copy link

codecov bot commented Jul 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Nice ❤️

@pi0 pi0 merged commit 2608148 into h3js:main Jul 30, 2025
3 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.

v2: Calling await next() in global middleware causes request handlers to be called twice

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载