- Pretty permalinks for this post:
- https://fireburn.ru/posts/kittybox-db-connection-leak
Ok. Past me made the dumbest mistake ever of ignoring documentation and using `std::panic::catch_unwind()` to catch a general application error. Basically I got resource exhaustion in the database connector and my website couldn’t connect to the database anymore. #IAmVeryDumb
Instead of catching panics, what I should’ve done (and what I’m doing now) is using `futures::stream::TryStreamExt::try_collect()` to turn a stream into a huge error if something fails inside it. In this case everything will be dropped, and the database connection returns to the pool whenever it’s dropped. No resource leaks anymore!
I hope you see less HTTP 500 errors from now on.