-
-
Notifications
You must be signed in to change notification settings - Fork 954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Memory leak using watchEvent #583
Comments
I am seeing similar results in other observers too. So likely not related to |
Think I found the culprit. It's in our |
can you try see if this still happens on the memory leak seems to be gone completely when i remove abort controllers, seems like we need to clean them up: 6be7922#diff-8b7a876b21ac77521fcb4a60160e0baceb18c2415682748d306b0d2fb445c480R35 |
I don't think it's about cleaning up the AbortController and instead more about cleaning up the lingering |
What do you mean? When I remove the AbortController completely, I no longer see a memory leak. |
Might be an issue with how built-in fetch handles signals: nodejs/node#46525 (comment) |
True. But when I run a script with short timeouts the memory still goes up so I suspect there's sth. with fetch? |
Good find. Maybe that's what I'm seeing? |
Can confirm that works to also clean up the lingering |
Looks like this was an issue with previous versions of Node, and was fixed downstream here: nodejs/undici#2049. Also related: #385 (reply in thread) I tried again on Node v20, and it seems to work fine. Solution: Update Node to |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread. |
Is there an existing issue for this?
Package Version
0.3.36
Current Behavior
Using the
watchEvent
function is leading to a growing memory consumption which can only be stopped using the unwatch function returned bywatchEvent
. Memory consumption will then stagnate.Expected Behavior
Memory consumption shouln't be evergrowing
Steps To Reproduce
A quick example running the following code will produce the graph attached after:
Using http transport (node v18.12.1):
Using ws transport (node v18.12.1):
Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: