-
Notifications
You must be signed in to change notification settings - Fork 257
await next in hono error handler middleware #2735
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
base: next
Are you sure you want to change the base?
Changes from all commits
9bee898
4888cac
a96aece
f037384
2e1d4e4
204231b
50b919e
553eade
aceb212
6c2ce64
71550b2
a2ba738
eb28535
2a5b89b
521b9db
5408358
2c37bcd
cef5117
fbc3cf4
f3c97a7
0dacde8
2d13751
daddba8
b092197
e69ccea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,7 +132,7 @@ Scenario: unhandled asynchronous exceptions are reported when using serverless-e | |
| And the event "session.events.unhandled" equals 1 | ||
|
|
||
| @hono-app | ||
| Scenario Outline: unhandled exceptions are reported when using hono | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These have no |
||
| Scenario: unhandled exceptions are reported when using hono | ||
| Given I setup the environment | ||
| When I invoke the "HonoFunction" lambda in "features/fixtures/hono-app" with the "events/unhandled.json" event | ||
| And the SAM exit code equals 0 | ||
|
|
@@ -156,7 +156,7 @@ Scenario Outline: unhandled exceptions are reported when using hono | |
| And the event "session.events.unhandled" equals 1 | ||
|
|
||
| @hono-app | ||
| Scenario Outline: unhandled asynchronous exceptions are reported when using hono | ||
| Scenario: unhandled asynchronous exceptions are reported when using hono | ||
| Given I setup the environment | ||
| When I invoke the "HonoFunction" lambda in "features/fixtures/hono-app" with the "events/unhandled-async.json" event | ||
| And the SAM exit code equals 0 | ||
|
|
@@ -179,3 +179,44 @@ Scenario Outline: unhandled asynchronous exceptions are reported when using hono | |
| And the event "session.events.handled" equals 0 | ||
| And the event "session.events.unhandled" equals 1 | ||
|
|
||
| @hono-app | ||
| Scenario: thrown non-error exceptions are reported when using hono | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
| Given I setup the environment | ||
| When I invoke the "HonoFunction" lambda in "features/fixtures/hono-app" with the "events/throw-non-error.json" event | ||
| Then the lambda response "errorMessage" equals "1" | ||
| And the lambda response "errorType" equals "number" | ||
| And the lambda response "body" is null | ||
| And the lambda response "statusCode" is null | ||
| And the SAM exit code equals 0 | ||
| When I wait to receive 2 errors | ||
|
|
||
| Then the error is valid for the error reporting API version "4" for the "Bugsnag Node" notifier | ||
| And the event "unhandled" is true | ||
| And the event "severity" equals "error" | ||
| And the event "severityReason.type" equals "unhandledException" | ||
| And the exception "errorClass" equals "Error" | ||
| And the exception "message" equals "1" | ||
| And the exception "type" equals "nodejs" | ||
| And the event "metaData.AWS Lambda context.functionName" equals "HonoFunction" | ||
| And the event "metaData.AWS Lambda context.awsRequestId" is not null | ||
| And the event "device.runtimeVersions.node" matches "^18\.\d+\.\d+$" | ||
|
|
||
| # Error thrown by hono | ||
| And I discard the oldest error | ||
| Then the error is valid for the error reporting API version "4" for the "Bugsnag Node" notifier | ||
| And the event "unhandled" is true | ||
| And the event "severity" equals "error" | ||
| And the event "severityReason.type" equals "unhandledErrorMiddleware" | ||
| And the exception "errorClass" equals "InvalidError" | ||
| And the exception "message" matches "hono middleware received a non-error\." | ||
| And the exception "type" equals "nodejs" | ||
| And the event "metaData.AWS Lambda context.functionName" equals "HonoFunction" | ||
| And the event "metaData.AWS Lambda context.awsRequestId" is not null | ||
| And the event "device.runtimeVersions.node" matches "^18\.\d+\.\d+$" | ||
|
|
||
| When I wait to receive a session | ||
| Then the session is valid for the session reporting API version "1" for the "Bugsnag Node" notifier | ||
| And the session "id" is not null | ||
| And the session "startedAt" is a timestamp | ||
| And the event "session.events.handled" equals 0 | ||
| And the event "session.events.unhandled" equals 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,22 +16,22 @@ const app = new Hono(); | |
| const middleware = Bugsnag.getPlugin('hono') | ||
|
|
||
| app.use(middleware.requestHandler) | ||
|
|
||
| app.use(middleware.errorHandler) | ||
|
|
||
| app.get('/', (c) => { | ||
| return c.text('Hello from Hono!') | ||
| }) | ||
|
|
||
| app.get('/handled', async (c, next) => { | ||
| Bugsnag.notify(new Error('handled')); | ||
| c.bugsnag.notify(new Error('handled')); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Bad assumption here! the |
||
| await next(); | ||
| }); | ||
|
|
||
| app.get('/sync', (c) => { | ||
| throw new Error('sync') | ||
| }) | ||
|
|
||
| // Causes the app to crash | ||
| app.get('/async', (c) => { | ||
| setTimeout(function () { | ||
| throw new Error('async') | ||
|
|
@@ -48,10 +48,17 @@ app.get('/rejection-async', (c) => { | |
| }, 100) | ||
| }) | ||
|
|
||
| app.get('/throw-non-error', async (c, next) => { | ||
| app.get('/throw-non-error', async (c) => { | ||
| throw 1 | ||
| }) | ||
|
|
||
| // Causes a 'Context is not finalized' Error if the error handler middleware does not `await next()` | ||
| app.post('/post-body', async (c) => { | ||
| await c.req.raw.json(); | ||
| c.bugsnag.notify(new Error('error in post body route')); | ||
| return c.json({ a: 'test' }); | ||
| }); | ||
|
|
||
| serve({ | ||
| fetch: app.fetch, | ||
| port: 80 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only upload artifacts when the tests fail so we can view the actual payloads