stream-js icon indicating copy to clipboard operation
stream-js copied to clipboard

ErrorAbstract is freezing Hermes engine (React Native)

Open sesm opened this issue 2 years ago • 4 comments

This line of code in ErrorAbstract is freezing Hermes JS engine in React Native applications: https://github.com/GetStream/stream-js/blob/main/src/errors.ts#L21

Please see minimal example React Native app here: https://github.com/sesm/rn-gestream-freeze

Related Hermes issue: https://github.com/facebook/hermes/issues/928

sesm avatar Mar 15 '23 17:03 sesm

Comment from Hermes team:

There is a bug in GetStream's AbstractError constructor. The call should be Error.captureStackTrace(this, AbstractError), and not Error.captureStackTrace(this, AbstractError.constructor).

( https://github.com/facebook/hermes/issues/928#issuecomment-1472584542 )

sesm avatar Mar 16 '23 21:03 sesm

@sesm Thank you for reporting. I've been banging my head up against the wall on this one.

nickstamas avatar Mar 17 '23 21:03 nickstamas

@nickstamas you are welcome! Here is a workaround patch just in case (copied from patch-package output):

diff --git a/node_modules/getstream/lib/errors.js b/node_modules/getstream/lib/errors.js
index 51108e3..80b9e7d 100644
--- a/node_modules/getstream/lib/errors.js
+++ b/node_modules/getstream/lib/errors.js
@@ -49,7 +49,7 @@ var ErrorAbstract = /*#__PURE__*/function (_Error) {
     (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "message", void 0);
     _this.message = msg;
 
-    if (canCapture) {
+    if (false) {
       Error.captureStackTrace((0, _assertThisInitialized2.default)(_this), ErrorAbstract.constructor);
     } else if (canStack) {
       _this.stack = new Error().stack;

sesm avatar Mar 18 '23 00:03 sesm

@sesm Thanks for this! That's now 2 heads saved from wall banging

TwistedMinda avatar Jul 18 '23 14:07 TwistedMinda