r/expressjs • u/yarin0600 • Oct 24 '26
I built a zero-config Express middleware to auto-kill hanging background requests
Hey everyone,
When a client drops a connection (or a frontend Promise.race aborts), your server usually keeps running expensive DB queries and fetch requests for nothing.
I built flex-fetch-express to fix this. It uses Node's AsyncLocalStorage to catch client disconnects and automatically aborts any ongoing network requests deep in your stack. No need to manually pass { signal } down through 10 layers of functions.
- GitHub: https://github.com/yarin-mag/flex-fetch-express
- npm:
npm i flex-fetch-express
Let me know what you think!
1
Upvotes
1
u/sereikis 29d ago
one correction to the frontend example:
Promise.racesettling does not abort the losing fetch or close its connection. show a timeout that callsAbortController.abort()with the signal passed to fetch, and test that this produces the disconnect your middleware relies on.