unjs / ofetch

😱 A better fetch API. Works on node, browser and workers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setTimeout controlling the timeout is never cleared on response or error

geminigeek opened this issue · comments

Environment

Node v20.10.0

Reproduction

just make a request with timeout, the node process only ends after the timeout period ends, the timeout is never cleared,
this timeout need to be cleared on response or error

setTimeout(() => controller.abort(), context.options.timeout);

setTimeout(() => controller.abort(), context.options.timeout);

Describe the bug

same as description

Additional context

tried to make PR but the formatting is crazy on my end

Logs

No response

I was at first very sceptic about this issue. In past 2 days I was discovering weird memory issues in my project.

After I have removed timeout setting from my project memory suddenly stopped rapidly groving.

I have managed to reproduce this in pure clean project. You have to enable asyncContext for this leak to be funnier. Repro: https://github.com/daniluk4000/nuxt-ofetch-memory-usage