facebook / memlab

A framework for finding JavaScript memory leaks and analyzing heap snapshots
https://facebook.github.io/memlab/
MIT License
4.3k stars 116 forks source link

RangeError: Invalid string length in LeakTraceDetailsLogger #121

Closed johnhok closed 1 week ago

johnhok commented 2 weeks ago

Error

I'm getting this an RangeError: Invalid string length when I run memlab in a CI environment.

Screenshot 2024-06-28 at 10 10 43 AM

It looks to be related to JSON.stringify in the LeakTraceDetailsLogger.

https://github.com/facebook/memlab/blob/16b4d9a3f1d383b02a67a4d87596f8a16c0d1f86/packages/core/src/logger/LeakTraceDetailsLogger.ts#L44

Notes

Does anyone have thoughts on alternative solutions to resolve this or have encountered a similar situation?

JacksonGL commented 2 weeks ago

RangeError: Invalid string length indicates that the string is too large, causing the JavaScript engine to throw an exception. Since the traceJSON result is not critical for most use cases, you can temporarily resolve this issue by commenting out the JSON.stringify statement and replacing it with something like:

const traceJSON = '{}';

I will add a guard check to this statement later.

johnhok commented 1 week ago

Are you planning on bumping the memlab versions? I see you have the proper fix in place now. Thanks for the help!

JacksonGL commented 1 week ago

@johnhok The fix is released in memlab@1.1.49. Thanks for reporting this issue