[React Native] [Thirdweb v5] ERROR TypeError: Cannot read property 'readFile' of undefined, js engine: hermes
ludwig-g-w opened this issue · 9 comments
It seems like this error has reappeared for me without any relevant changes to my dependencies. I've tried to create a new Thirdweb client Id which hasn't solved the issue. Here's the error:
ERROR TypeError: Cannot read property 'readFile' of undefined, js engine: hermes
Error: Malformed response from post authentication: Something went wrong getting cognito recovery code
@ludwig-g-w what are the steps you're doing to reproduce this? some code would be helpful too. And is it consistently failing with that error?
I encounter this error consistently whenever I try to login using whatever method otp, Apple(I think same result when using wallets as well) native wallet works fine. The strange thing is that two weeks ago these same methods were working, no changes in the code since then. The only change I have done now is to update my API key.
I don't know if it's of any help but the error is pointing to this file: getSSOTokenFromFile.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSSOTokenFromFile = void 0;
const fs_1 = require("fs");
const getSSOTokenFilepath_1 = require("./getSSOTokenFilepath");
const { readFile } = fs_1.promises;
const getSSOTokenFromFile = async (id) => {
const ssoTokenFilepath = (0, getSSOTokenFilepath_1.getSSOTokenFilepath)(id);
const ssoTokenText = await readFile(ssoTokenFilepath, "utf8");
return JSON.parse(ssoTokenText);
};
exports.getSSOTokenFromFile = getSSOTokenFromFile;
hmmm that code doesnt look familiar, its not from our library - is it from another library maybe?
After looking a bit further it seems to be this function that is throwing the error: Something went wrong getting cognito recovery code
async function getRecoveryCode(
storedToken: AuthStoredTokenWithCookieReturnType["storedToken"],
client: ThirdwebClient,
recoveryCode?: string,
): Promise<string> {
if (
storedToken.authDetails.recoveryShareManagement ===
RecoveryShareManagement.CLOUD_MANAGED
) {
if (
storedToken.authProvider === AuthProvider.CUSTOM_JWT ||
storedToken.authProvider === AuthProvider.CUSTOM_AUTH_ENDPOINT
) {
if (!recoveryCode) {
throw new Error(
`GetRecoveryCode error: ${ErrorMessages.missingRecoveryCode}`,
);
}
return recoveryCode;
} else {
try {
const code = await getCognitoRecoveryPassword(client);
return code;
} catch (e) {
throw new Error("Something went wrong getting cognito recovery code");
}
}
} else if (
storedToken.authDetails.recoveryShareManagement ===
RecoveryShareManagement.USER_MANAGED
) {
if (recoveryCode) {
return recoveryCode;
}
throw new Error(ErrorMessages.missingRecoveryCode);
} else {
throw new Error("Invalid recovery share management option");
}
}
how consistent is this? you can reproduce everytime?
It always happens for me in two different apps as well.
very weird im not able to reproduce. Does it happen with every email for you or only certain ones? the error seems to indicate that either the account or client id was used in a different way before...
@ludwig-g-w can you try updating to latest (5.43+) we shipped a fix related to this issue