microsoft / v8-jsi

React Native V8 JSI adapter
Other
161 stars 37 forks source link

JSError stack includes the message #136

Open tudorms opened 2 years ago

tudorms commented 2 years ago

Per V8's documentation, the Error.stack property will include the message as well, but JSI tracks "message" and "stack" as separate properties.

We need to find a way to strip the message out of the "stack" in JSError.

tudorms commented 2 years ago

Note: my initial thought of searching for message and stripping it out of stack may not work. For example, for a stack overflow message returns Uncaught #<Object>, while stack looks like this:

RangeError: Maximum call stack size exceeded
    at eval (eval at f (eval at <anonymous> (unknown source)), <anonymous>:1:1)
    at eval (<anonymous>)
    at f (eval at <anonymous> (unknown source), <anonymous>:1:1)
    at f (eval at <anonymous> (unknown source), <anonymous>:1:1)
    at f (eval at <anonymous> (unknown source), <anonymous>:1:1)
    at f (eval at <anonymous> (unknown source), <anonymous>:1:1)
    at f (eval at <anonymous> (unknown source), <anonymous>:1:1)
    at f (eval at <anonymous> (unknown source), <anonymous>:1:1)
    at f (eval at <anonymous> (unknown source), <anonymous>:1:1)
    at f (eval at <anonymous> (unknown source), <anonymous>:1:1)

We could try reconstructing the stack out of individual call frames to have the same format, but it could get messy and not sure if all information needed is available.