enisdenjo / graphql-sse

Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client.
https://the-guild.dev/graphql/sse
MIT License
384 stars 19 forks source link

Possible memory leak on Client.listeners #106

Open devunt opened 3 weeks ago

devunt commented 3 weeks ago

If an established subscription is disposed by calling its dispose function (which is returned by subscribe method itself), which is pretty common scenario, a memory leak occurs in the Client. A listeners field keep track callbacks which will get called when Client.dispose() method is called, but it doesn't properly clean up the callback if the subscription is disposed individually. This leads to constantly growing Client.listeners array if the subscription is frequently created and disposed through application's lifecycle.

CleanShot 2024-09-05 at 16 52 58