rpc-errors icon indicating copy to clipboard operation
rpc-errors copied to clipboard

React-Native crashed when try access `err.stack`

Open ieow opened this issue 1 year ago • 2 comments

React Native app crashed when try to access stack field in the error object

in reactNative ( version 0.72.0 )

to reproduce (in react native)

    import {rpcErrors} from '@metamask/rpc-errors';
    
    try {
      let err = rpcErrors.invalidRequest();
      console.log(err.stack);
    } catch (error) {
      console.log(error);
    }

Accessing stack in Error class works fine

   try {
     let err = new Error("error message");
     console.log(err.stack);
   } catch (error) {
     console.log(error);
   }

ieow avatar Feb 02 '24 05:02 ieow

+1

LeeNorth avatar Mar 29 '24 11:03 LeeNorth

Assigning a potentially cyclic object directly to serialized.stack is not safe.

Suggestion: Perform explicit serialization of the stack with a max-depth of recursion, or prune the reference.

legobeat avatar Jul 23 '24 03:07 legobeat