[zod, bun]#openapi async/await doesn't work
This ossue was previously on https://discord.com/channels/1011308539819597844/1012485912409690122/1242558525012709539, but I was advised to open it here.
here is a noob question. Im quite new to TS, bun and Hono with Zod. I cant make sense of why TS is screaming at me in the first line with async
the error reads
I think im returning my result wrong? it works fine, when returning it normally without my DB stuff and async/await
I havent tried running it with that error.. but I kind of want to resolve it first regardless.
8 Replies
Hey! Typescript enjoys yelling. I think we’d need to see more code! My initial thought is the
apps.openapi
is not inferring types correctly. Understanding why requires seeing how everything was set up before being wired together
if you can link to a repo that’d be idealPromise<TypedResponse<{ id?: number; identifier?: string; features?: { featureX?: boolean; featureY?: number; }; }, 200, "json">>
GitHub
[zod-openapi] Unable to use async handler · Issue #521 · honojs/mid...
hono: 4.3.6 before @hono/zod-openapi: 0.11.1 after @hono/zod-openapi: 0.12.0 After updating from version 0.11.1 to version 0.12.0, I get a type error when using async handler. const app = new OpenA...
Exception - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
GitHub
GitHub - NicoPlyley/hono-error-handler
Contribute to NicoPlyley/hono-error-handler development by creating an account on GitHub.
For anyone else looking the issue is from
if (!result) return c.notFound();
You need to throw an Error instead of returning a different response directly from the controller