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

feat(trpc-server): Use honoReq's bodyCache to provide a body function for trpc's req #850

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

Gaubee
Copy link
Contributor

@Gaubee Gaubee commented Nov 28, 2024

Some middleware (in createContext) may need to read the body. If the raw request instance is provided directly, the body will be consumed prematurely, blocking the development of middleware.

Copy link

changeset-bot bot commented Nov 28, 2024

🦋 Changeset detected

Latest commit: 7105516

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

This PR includes changesets to release 1 package
Name Type
@hono/trpc-server 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

@yusukebe yusukebe changed the title :feat Use honoReq's bodyCache to provide a body function for trpc's req feat(trpc-server) Use honoReq's bodyCache to provide a body function for trpc's req Nov 29, 2024
@yusukebe yusukebe changed the title feat(trpc-server) Use honoReq's bodyCache to provide a body function for trpc's req feat(trpc-server): Use honoReq's bodyCache to provide a body function for trpc's req Nov 29, 2024
@yusukebe
Copy link
Member

Hi @Gaubee

This is interesting. It looks good. But one thing. Can you run yarn changeset on the top of this repo and push the changeset file? I think this is not a new feature for users, so this will be a patch update.

Some middleware (in createContext) may need to read the body. If the raw request instance is provided directly, the body will be consumed prematurely, blocking the development of middleware.
Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

yusukebe commented Dec 2, 2024

@Gaubee

Thank you! I'll merge this and release the new version.

@yusukebe yusukebe merged commit ee83665 into honojs:main Dec 2, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request Dec 2, 2024
@buwon
Copy link

buwon commented Dec 2, 2024

When I apply this version, I get an error.

The Request.url getter can only be used on instances of Request

The error occurs at the following location.

https://github.com/trpc/trpc/blob/4b7757d9f426ab4eaa2c13153c2b3c5c5557eef5/packages/server/src/adapters/fetch/fetchRequestHandler.ts#L35

It occurs when I call mutate with hono + trpc.
Is the usage changed from before?

@yusukebe
Copy link
Member

yusukebe commented Dec 2, 2024

@Gaubee Can you handle it?

@Gaubee
Copy link
Contributor Author

Gaubee commented Dec 2, 2024

When I apply this version, I get an error.

The Request.url getter can only be used on instances of Request

The error occurs at the following location.

https://github.com/trpc/trpc/blob/4b7757d9f426ab4eaa2c13153c2b3c5c5557eef5/packages/server/src/adapters/fetch/fetchRequestHandler.ts#L35

It occurs when I call mutate with hono + trpc. Is the usage changed from before?

so you use bunjs? fix pr in #864

@buwon
Copy link

buwon commented Dec 3, 2024

Yes. I use Bun v1.1.38.
#864 works fine.
Thank you.

askorupskyy pushed a commit to askorupskyy/hono-middleware that referenced this pull request Dec 18, 2024
…eq (honojs#850)

Some middleware (in createContext) may need to read the body. If the raw request instance is provided directly, the body will be consumed prematurely, blocking the development of middleware.
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.

None yet

3 participants