Why not async-wrap everything by default?
Closed this issue · 2 comments
Hi,
I'm currently using custom versions of Controller
, Middleware
to forcefully produce async-wrapped handlers.
- For controller, it's easy, I force add a class wrapper with async handler
- For middleware, I have to create my own version of the decorator, which wraps all middleware given in a loop, and hands the result to the real middleware decorator
This are two ways someone can shoot themselves in the foot
https://github.com/seanpmaxwell/overnight/blob/master/src/core/lib/Server.ts#L146 - note the class middleware is not wrapped or treated
https://github.com/seanpmaxwell/overnight/blob/master/src/core/lib/Server.ts#L174 - note the middleware part is not wrapped or is not treated
Basically, there are 2 points that we can wrap async inside overnight, and have the end user not worry about this at all
https://github.com/seanpmaxwell/overnight/blob/master/src/core/lib/Server.ts#L146 - wrap
https://github.com/seanpmaxwell/overnight/blob/master/src/core/lib/Server.ts#L174 - wrap all middleware + callback
So why not treat this at the overnight core? as far as I see there's no real disadvantage and there's a big risk that right now people are running in production not being aware of this, for example for the nuance that middleware too can get bitten by async errors not propagating
Well the reason I don't do that is because ExpressJS doesn't do that. I'm not trying to create an abstraction over ExpressJS, just provide decorators.
I'm close this cause no activity