react-native icon indicating copy to clipboard operation
react-native copied to clipboard

TypeError: Error.stack getter called with an invalid receiver, js engine: hermes

Open MTalhaAC opened this issue 1 year ago • 12 comments

Description

After upgrading the version of react native to 0.17.3 whenever I moved through the tap navigation the following error message shown.

Screenshot 2024-03-24 194437

In the Visual Studio Code the following path contains the code node_modules\react-native\Libraries\promiseRejectionTrackingOptions.js

Screenshot 2024-03-24 194636

After replacing the rejection. stack with the rejection of all work fine.

Steps to reproduce

  1. Upgrade the existing React native version to 0.73.6.
  2. Run the application.
  3. Everything works fine but when the screen.

React Native Version

0.73.6

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: Windows 11 10.0.22631
  CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  Memory: 6.78 GB / 15.88 GB
Binaries:
  Node:
    version: 18.17.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 9.6.7
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-231.9392.1.2311.11330709
  Visual Studio:
    - 17.8.34322.80 (Visual Studio Community 2022)
Languages:
  Java:
    version: 17.0.10
    path: C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

TypeError: Error.stack getter called with an invalid receiver, js engine: hermes

Reproducer

https://github.com/MTalhaAC/EnlightenAppv0.0.1

Screenshots and Videos

Screenshot 2024-03-24 194437 Screenshot 2024-03-24 194636

MTalhaAC avatar Mar 24 '24 14:03 MTalhaAC

any solution for this ?

mrrjatt avatar Apr 01 '24 10:04 mrrjatt

@mrrjatt > any solution for this ?

In the Visual Studio Code, the following path contains the code node_modules\react-native\Libraries\promiseRejectionTrackingOptions.js

Screenshot 2024-03-24 194636

After replacing the rejection.stack with the rejection all works fine.

I know it is not the solution to that issue ... but It works for me ...

MTalhaAC avatar Apr 01 '24 11:04 MTalhaAC

@mrrjatt > any solution for this ?

In the Visual Studio Code, the following path contains the code node_modules\react-native\Libraries\promiseRejectionTrackingOptions.js

Screenshot 2024-03-24 194636

After replacing the rejection.stack with the rejection all works fine.

I know it is not the solution to that issue ... but It works for me ...

thank you very much ,, but I solved by disabling herms and it worked.

mrrjatt avatar Apr 09 '24 01:04 mrrjatt

Would you like to share? How do you disable the herms?


From: mrrjatt @.> Sent: Tuesday, April 9, 2024 6:09 AM To: facebook/react-native @.> Cc: Muhammad Talha @.>; Author @.> Subject: Re: [facebook/react-native] TypeError: Error.stack getter called with an invalid receiver, js engine: hermes (Issue #43636)

@mrrjatthttps://github.com/mrrjatt > any solution for this ?

In the Visual Studio Code, the following path contains the code node_modules\react-native\Libraries\promiseRejectionTrackingOptions.js

[Screenshot 2024-03-24 194636]https://private-user-images.githubusercontent.com/138590130/318423740-af4168d7-70a7-4afc-8606-0d07c36d87bb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTI2MjUxMjgsIm5iZiI6MTcxMjYyNDgyOCwicGF0aCI6Ii8xMzg1OTAxMzAvMzE4NDIzNzQwLWFmNDE2OGQ3LTcwYTctNGFmYy04NjA2LTBkMDdjMzZkODdiYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNDA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDQwOVQwMTA3MDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iMjllMGJiOTA4NDBkZTcyZGY3Y2VjOGZjNWRiYTUzMzQ1MjNiNjE3NWZkMTgyOTEzYTc2YmU4OWZmYmZiM2I5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9._Ct3kpo2IpwoC5rGimxG9HiQvECqLL6RXHhfbslR9WU

After replacing the rejection.stack with the rejection all works fine.

I know it is not the solution to that issue ... but It works for me ...

thank you very much ,, but I solved by disabling herms and it worked.

— Reply to this email directly, view it on GitHubhttps://github.com/facebook/react-native/issues/43636#issuecomment-2043957265, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BBBLPMT3MDA2XYTEN3IARH3Y4M5ULAVCNFSM6AAAAABFFYIAZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBTHE2TOMRWGU. You are receiving this because you authored the thread.Message ID: @.***>

MTalhaAC avatar Apr 09 '24 04:04 MTalhaAC

Would you like to share? How do you disable the herms? ________________________________ From: mrrjatt @.> Sent: Tuesday, April 9, 2024 6:09 AM To: facebook/react-native @.> Cc: Muhammad Talha @.>; Author @.> Subject: Re: [facebook/react-native] TypeError: Error.stack getter called with an invalid receiver, js engine: hermes (Issue #43636) @mrrjatthttps://github.com/mrrjatt > any solution for this ? In the Visual Studio Code, the following path contains the code node_modules\react-native\Libraries\promiseRejectionTrackingOptions.js [Screenshot 2024-03-24 194636]https://private-user-images.githubusercontent.com/138590130/318423740-af4168d7-70a7-4afc-8606-0d07c36d87bb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTI2MjUxMjgsIm5iZiI6MTcxMjYyNDgyOCwicGF0aCI6Ii8xMzg1OTAxMzAvMzE4NDIzNzQwLWFmNDE2OGQ3LTcwYTctNGFmYy04NjA2LTBkMDdjMzZkODdiYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNDA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDQwOVQwMTA3MDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iMjllMGJiOTA4NDBkZTcyZGY3Y2VjOGZjNWRiYTUzMzQ1MjNiNjE3NWZkMTgyOTEzYTc2YmU4OWZmYmZiM2I5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9._Ct3kpo2IpwoC5rGimxG9HiQvECqLL6RXHhfbslR9WU After replacing the rejection.stack with the rejection all works fine. I know it is not the solution to that issue ... but It works for me ... thank you very much ,, but I solved by disabling herms and it worked. — Reply to this email directly, view it on GitHub<#43636 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BBBLPMT3MDA2XYTEN3IARH3Y4M5ULAVCNFSM6AAAAABFFYIAZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBTHE2TOMRWGU. You are receiving this because you authored the thread.Message ID: @.***>

i disabled them by going to build.gradle and turning the herms flag to false

mrrjatt avatar Apr 15 '24 02:04 mrrjatt

I'm having the same issue, is there any update on this?

pixelsomatic avatar Jun 04 '24 06:06 pixelsomatic

I just disabled the herms flag in the build.gradle to false.


From: Kris @.> Sent: Tuesday, June 4, 2024 11:18 AM To: facebook/react-native @.> Cc: Muhammad Talha @.>; Author @.> Subject: Re: [facebook/react-native] TypeError: Error.stack getter called with an invalid receiver, js engine: hermes (Issue #43636)

I'm having the same issue, is there any update on this?

— Reply to this email directly, view it on GitHubhttps://github.com/facebook/react-native/issues/43636#issuecomment-2146699066, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BBBLPMRUFZDCNYNL5JKNSITZFVL3HAVCNFSM6AAAAABFFYIAZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBWGY4TSMBWGY. You are receiving this because you authored the thread.Message ID: @.***>

MTalhaAC avatar Jun 05 '24 06:06 MTalhaAC

what's causing this issue ?

yourjhay avatar Jul 25 '24 00:07 yourjhay

what's causing this issue ?

Not sure but maybe the framework is throwing as of some issue in stack navigator as this happens to be seen when something is wrong with navigation.

mrrjatt avatar Jul 27 '24 19:07 mrrjatt

how you to fix this issue bro

daniels9028 avatar Aug 21 '24 22:08 daniels9028

how you to fix this issue bro

go to build.gradle and disable herms flag

mrrjatt avatar Aug 25 '24 15:08 mrrjatt

I was having the same problem using expo 51. I just removed the package-lock.json and node_modules, run npm install again, clean the data of Expo Go app, and it worked to me.

lnfernandobr avatar Sep 03 '24 21:09 lnfernandobr

Also having this issue after upgrading from Expo 49 to 51:

Simulator Screenshot - iPhone 15 Pro Max - 2024-09-20 at 09 55 16

This happens on iOS locally and on physical devices right after starting the app and only appears at the very beginning. When restarting the app, everything works fine. After a while NOT using the app at all the error occurs again. Therefore, it can be hard to reproduce.

jrafflenbeul avatar Sep 20 '24 10:09 jrafflenbeul

same, absolutely random throwing exception in app lifetime

"react-native": "0.76.3"

whalemare avatar Jan 12 '25 12:01 whalemare

I've having the same issue is there any solution?

zaidqureshi95 avatar Feb 03 '25 14:02 zaidqureshi95

same, this happened to me after an hour in background mode.

Azelesnkiy avatar Feb 10 '25 13:02 Azelesnkiy

Getting this error when axios throws its AxiosError

NepeinAV avatar Feb 11 '25 12:02 NepeinAV

any update here ? We are facing this issue with "react-native": "0.76.6"

SamNassifOstrom avatar Feb 17 '25 16:02 SamNassifOstrom

Has anyone figured this out?

KrisLau avatar Mar 01 '25 14:03 KrisLau

face the same issue on 0.76.6. any resolution here?

John251314 avatar Mar 13 '25 07:03 John251314

I found the error can be catch by global error handler, like this:

ErrorUtils.setGlobalHandler(error => {
    console.log('error is ', error);
});

log:

 WARN  Possible Unhandled Promise Rejection (id: 0):
Error: FLOW_CANCELLED
 LOG  error is  [TypeError: Error.stack getter called with an invalid receiver]
 WARN  Possible Unhandled Promise Rejection (id: 1):
Error: FLOW_CANCELLED
 WARN  Possible Unhandled Promise Rejection (id: 2):
Error: FLOW_CANCELLED
 LOG  error is  [TypeError: Error.stack getter called with an invalid receiver]
 LOG  error is  [TypeError: Error.stack getter called with an invalid receiver]
 WARN  Possible Unhandled Promise Rejection (id: 3):
Error: FLOW_CANCELLED

because FLOW_CANCELLED is not the error object

John251314 avatar Mar 13 '25 07:03 John251314

Getting this error when axios throws its AxiosError

Same for me. Everytime .stack is called on an AxiosError this exception is thrown and since we're using Sentry its internals call .stack on thrown errors (including axios ones) which results in this exception.

It seems that the fix for the error in the hermes engine has already been merged but a new version with the fix is not released yet (I think).

For axios specifically it seems that it relates to the way object inheritance was handled in the past as mentioned in: facebook/hermes#1496

For now I've just written to the .stack property manually by taking the stack of a newly constructed error.

file: node_modules/axios/lib/core/AxiosError.js

function AxiosError(message, code, config, request, response) {
  Error.call(this);
  this.message = message;
  this.name = 'AxiosError';
  code && (this.code = code);
  config && (this.config = config);
  request && (this.request = request);
  response && (this.response = response);

  // add this line (and create a patch package)
  this.stack = new Error().stack;
}

This is more of a patch/hacky solution since I'm not sure whether we're not losing the original stack information by taking the stack of a newly constructed error but it works while we wait for a new version of the hermes engine.

Another potential solution that seemed to work was rewriting the AxiosError function to be a standard class and extending Error but I don't know if this has some other implications in the library so this is fine for now.

pavel-roj avatar Mar 20 '25 09:03 pavel-roj

Same error when throwing custom error:

export class CustomError extends Error {
  constructor(
    public readonly message: string,
  ) {
    super(message);
  }
}

With react-native 0.78.0

LaGregance avatar Mar 20 '25 10:03 LaGregance

Getting this error when axios throws its AxiosError

I fixed it this way:
console.error("Error setting Axios incerceptors", _.toString(error));

redbluenat avatar Apr 03 '25 11:04 redbluenat

When will the solution be released?

amexoz avatar Apr 13 '25 21:04 amexoz

Same error when throwing custom error:

export class CustomError extends Error { constructor( public readonly message: string, ) { super(message); } } With react-native 0.78.0

Did you fix it?

System-Garcia avatar Apr 16 '25 01:04 System-Garcia

In my case, the error was caused by the refresh-fetch library. Replacing it with the standard fetch (or using axios with axios-auth-refresh) solved the problem.

Azelesnkiy avatar Apr 16 '25 07:04 Azelesnkiy

folks that are getting this error cause of axios (eg. @NepeinAV or @pavel-roj) - what version are you on/were you on when the error occured?

szarbartosz avatar Jun 09 '25 10:06 szarbartosz

@szarbartosz

react-native: 0.77.1
axios: 1.9.0

To resolve this problem we wrote this wrapper

import axios, { type AxiosError, type AxiosResponse, type InternalAxiosRequestConfig } from 'axios';

export class HttpError<T = unknown, D = unknown> extends Error {
    config?: InternalAxiosRequestConfig<D>;

    code?: string;

    request?: unknown;

    response?: AxiosResponse<T, D>;

    isAxiosError: boolean;

    status?: number;

    constructor(error: AxiosError<T, D>) {
        super(error.message, { cause: error });

        this.config = error.config;
        this.code = error.code;
        this.request = error.request;
        this.response = error.response;
        this.isAxiosError = error.isAxiosError;
        this.status = error.status;
    }
}

export const isHttpError = (error: unknown): error is HttpError => axios.isAxiosError(error);

NepeinAV avatar Jun 09 '25 11:06 NepeinAV

@NepeinAV And how do you use this wrapper?

amexoz avatar Jun 09 '25 11:06 amexoz