TypeError: Error.stack getter called with an invalid receiver, js engine: hermes
Description
After upgrading the version of react native to 0.17.3 whenever I moved through the tap navigation the following error message shown.
In the Visual Studio Code the following path contains the code node_modules\react-native\Libraries\promiseRejectionTrackingOptions.js
After replacing the rejection. stack with the rejection of all work fine.
Steps to reproduce
- Upgrade the existing React native version to 0.73.6.
- Run the application.
- 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
any solution for this ?
@mrrjatt > any solution for this ?
In the Visual Studio Code, the following path contains the code node_modules\react-native\Libraries\promiseRejectionTrackingOptions.js
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 ...
@mrrjatt > any solution for this ?
In the Visual Studio Code, the following path contains the code node_modules\react-native\Libraries\promiseRejectionTrackingOptions.js
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.
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
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: @.***>
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
I'm having the same issue, is there any update on this?
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: @.***>
what's causing this issue ?
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.
how you to fix this issue bro
how you to fix this issue bro
go to build.gradle and disable herms flag
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.
Also having this issue after upgrading from Expo 49 to 51:
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.
same, absolutely random throwing exception in app lifetime
"react-native": "0.76.3"
I've having the same issue is there any solution?
same, this happened to me after an hour in background mode.
Getting this error when axios throws its AxiosError
any update here ? We are facing this issue with "react-native": "0.76.6"
Has anyone figured this out?
face the same issue on 0.76.6. any resolution here?
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
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.
Same error when throwing custom error:
export class CustomError extends Error {
constructor(
public readonly message: string,
) {
super(message);
}
}
With react-native 0.78.0
Getting this error when
axiosthrows its AxiosError
I fixed it this way:
console.error("Error setting Axios incerceptors", _.toString(error));
When will the solution be released?
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?
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.
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
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 And how do you use this wrapper?
