DEV Community

Ramadan Ahmed
Ramadan Ahmed

Posted on

That inflight memory leak warning in your npm install? Here's the fix

**Every npm install. Same warning.

npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory.

Next.js. Jest. Angular. All of them. You've seen it. You've ignored it.
Here's what inflight actually does, it deduplicates async calls. Same function called 10 times simultaneously? Only one runs, all 10 get the result. Useful. But it never cleans up. Keys stay in memory forever. That's the leak.
I built the replacement.

npm install @firekid/once
import { once } from '@firekid/once'

const getUser = once(async (id: string) => {
return await db.users.findUnique({ where: { id } })
})

// 10 requests hit at once — 1 DB query fires
const user = await getUser('123')
Auto cleanup. Full TypeScript. Works in Node, Edge, Bun, browser. Zero dependencies.
One line to stop the warning and fix the leak.

GitHub: github.com/Firekid-is-him/once
npm: npmjs.com/package/@firekid/once**

Top comments (0)