Need help with c.executionCtx.passThroughOnException()
#1178
Replies: 3 comments
-
|
If your purpose is simply to avoid showing the "Internal Server Error" to users, you can use https://hono.dev/api/hono#error-handling app.onError((e, c) => {
console.log(e)
return c.text('!', 500)
}) |
Beta Was this translation helpful? Give feedback.
-
|
Hey @yusukebe ! Thanks a lot for reply. https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#passthroughonexception is crucial functionality. It allows team to develop worker being confident that whatever happens - this command prevents from any bad stuff happenning. Can't it be replicated to behave identically as in CF workers? |
Beta Was this translation helpful? Give feedback.
-
|
I've never used app.onError((e, _c) => {
throw e
})
export default {
fetch: (request: Request, env: {}, context: ExecutionContext) => {
context.passThroughOnException()
return app.fetch(request, env, context)
}
}Does it work as expected? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
I've encountered an issue with
c.executionCtx.passThroughOnException(). In my Hono setup, it doesn't prevent theInternal Server Errorfrom appearing in the browser, as I believe it should.I initialized the worker with
npm create hono@latest my-app. The error persists even when the code is updated as follows:However, when I refactored my code without Hono,
passThroughOnExceptionfunctioned as expected, preventing theInternal Server Error:Why does
passThroughOnExceptionget ignored with a Hono setup?Beta Was this translation helpful? Give feedback.
All reactions