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 hono adapter #528

Merged
merged 3 commits into from
Feb 10, 2024
Merged

Fix hono adapter #528

merged 3 commits into from
Feb 10, 2024

Conversation

joshgillies
Copy link
Contributor

Experiencing the following errors when using Hono and grammY.

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] 123 | /** hono web framework */

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] 124 | const hono = (ctx) => {

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] 125 | let resolveResponse;

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] 126 | return {

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] 127 | update: ctx.req.json(),

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] 128 | header: ctx.req.headers.get(SECRET_HEADER) || undefined,

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] ^

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] TypeError: undefined is not an object (evaluating 'ctx.req.headers.get')

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] at hono (/app/node_modules/grammy/out/convenience/frameworks.js:128:17)

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] at /app/node_modules/grammy/out/convenience/webhook.js:23:79

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] at /app/node_modules/grammy/out/convenience/webhook.js:22:22

2024-02-10T06:11:33.126 app[90806145c55418] syd [info] at dispatch (/app/node_modules/hono/dist/hono-base.js:213:15)

2024-02-10T06:11:33.127 app[90806145c55418] syd [info] TypeError: Request aborted

2024-02-10T06:11:33.127 app[90806145c55418] syd [info] code: "ABORT_ERR"

The fix ensures we correctly access the incoming header via the correct Hono API: c.req.header.

@joshgillies joshgillies marked this pull request as ready for review February 10, 2024 06:57
Copy link

codecov bot commented Feb 10, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (bd67f5b) 46.05% compared to head (659ee31) 46.06%.

Files Patch % Lines
src/convenience/frameworks.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #528   +/-   ##
=======================================
  Coverage   46.05%   46.06%           
=======================================
  Files          19       19           
  Lines        6051     6050    -1     
  Branches      320      320           
=======================================
  Hits         2787     2787           
+ Misses       3261     3260    -1     
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@KnorpelSenf KnorpelSenf left a comment

Choose a reason for hiding this comment

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

Nice one, thanks!

@KnorpelSenf
Copy link
Member

@all-contributors add @joshgillies for this code

@KnorpelSenf KnorpelSenf merged commit 142f68d into grammyjs:main Feb 10, 2024
8 checks passed
Copy link
Contributor

@KnorpelSenf

I've put up a pull request to add @joshgillies! 🎉

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.

2 participants