middie icon indicating copy to clipboard operation
middie copied to clipboard

Update index.d.ts

Open juliusmarminge opened this issue 1 year ago • 2 comments

excuse me if this is invalid but from reading the examples it seems like async functions are allowed, so the return type should accept a promise?

i've been thrown off from all the synchronous types in Fastify the last couple of days, so perhaps this should be looked over in other parts of the ecosystem too

juliusmarminge avatar Jun 14 '24 08:06 juliusmarminge

What examples? Are those on our website?

You really should not use async here, nor in most other middleware, because there is no real error handling for rejecting promises. Nor there is in express or connect etc.

In essence, the types are telling you that what you are doing is essentially unsafe, because it is.

mcollina avatar Jun 14 '24 09:06 mcollina

In express v4 I needed to use this one "hack" where you could have async handlers. I think express v5 has native async handler support.

Uzlopak avatar Sep 11 '24 07:09 Uzlopak

@juliusmarminge Do you want to also tackle the issues raised by mcollina, or can this PR be closed?

Fdawgs avatar Mar 27 '25 09:03 Fdawgs

Closing due to discussion above re extra work needed, and no activity.

Fdawgs avatar Apr 15 '25 08:04 Fdawgs