vhtml
vhtml copied to clipboard
SSR Memory leak
I recently added this package in our project and I was told it's causing memory leak in our prod env.
After reading the code, it seems like it's the sanitized cache that's causing the problem.
sanitized[s] = true;
Every generated html string(s) would be stored in this cache, and it seems to have caused our server run out of memory and keeps restarting.
Has it been solved?
This is still an issue. Switching to a WeakMap would likely help. I opened a PR with a basic implementation.
It seems like the problem has not been solved yet. Is there any plan? ðŸ˜
I'm integrating part of this library in an experiment and ran into this issue.
another potential solution is to add an indicator to the "child" that it was generated by h() so no need to store any global collection. the child could add a property to the html string it returns (not sure if this has browser memory implications and it's kind of hacky).
or instead of returning the string s maybe return lightest possible object structure with a toString() method
e.g. { h: true, toString() { return s; } }