Gateway Timeouts and Error occurred while getting current epoch

When asking for help in this category, please make sure to provide the following details:

  • SDK Version: 9.5.0
  • Platform: SFA - NodeJS
  • Browser Console Screenshots: NA
  • If the issue is related to Custom Authentication, please include the following information (optional):
    • Verifier Name: sliver-firebase-auth-test
    • JWKS Endpoint: https://www.googleapis.com/service_accounts/v1/jwk/firebase-adminsdk-djs67@tbdzabn8uv-d33a0.iam.gserviceaccount.com
    • Sample idToken (JWT): eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2lkZW50aXR5dG9vbGtpdC5nb29nbGVhcGlzLmNvbS9nb29nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsImlhdCI6MTc0OTUyOTQ2NiwiZXhwIjoxNzQ5NTMzMDY2LCJpc3MiOiJmaXJlYmFzZS1hZG1pbnNkay1kanM2N0B0YmR6YWJuOHV2LWQzM2EwLmlhbS5nc2VydmljZWFjY291bnQuY29tIiwic3ViIjoiZmlyZWJhc2UtYWRtaW5zZGstZGpzNjdAdGJkemFibjh1di1kMzNhMC5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbSIsInVpZCI6InFjSTlmMnpER1hNaEZLeEw0SGhHeVVVaGVyNzMiLCJjbGFpbXMiOnsicmFuZG9tVVVJRCI6IjYxMjA2ZDZjLWZlODctNDdjZi04MGM5LTFhNjk1Y2NhNjY5NyJ9fQ.uppWhECoEbmDt-SHYdlb2YYDA_s8Uvt2zXKBQSMBFKrtE4kds1KzJ19HhAkBkBlOAX4lKmWe1_fKAVi7PzEgi2GGXZojcz7hja33-pdvh3j0ENCInlBFLM2G2vr7i9m4XRI6g_52OGlgzDCtYHvesrJHxxMU58UYwKB_fz9iy1PaSNRrW8CLCX264aHpL92os8E1I4PQnAhD8d9V_nogfzkECESCIgH38a_joaJBO4BG4_ipLkpaJ–TE5Sx9SUwZIjuVkvQhBEMdpAMTQNBNDnDiQLDP2gSh6v1f4AYHSIZx8BlK-V6TKuXe4z6VbfQHM2_DM-U_n_-sXTSISzoEw

Also, kindly provide the Web3Auth initialization and login code snippet below. This will help us better understand your issue and provide you with the necessary assistance.

Code


const chainConfig = {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId: "0x1",
    rpcTarget: config.MAINNET_RPC_URL,
    displayName: "Mainnet",
    ticker: "ETH",
    tickerName: "Ethereum",

};


const chainConfigBatch = {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId: "0x1",
    rpcTarget: config.MAINNET_BATCH_RPC_URL,
    displayName: "Mainnet",
    ticker: "ETH",
    tickerName: "Ethereum",

};

const privateKeyProviderMain = new EthereumPrivateKeyProvider({ config: { chainConfig } });
const privateKeyProviderBatch = new EthereumPrivateKeyProvider({ config: { chainConfig: chainConfigBatch } });

const CACHE = new ExpiringCache<string>();

export const populateWallets = async (req: Request, resp: Response, next: NextFunction) => {
    try {
        const userId = (req.user as any).uid;


        let privateKey = null;

        for (const privateKeyProvider of [privateKeyProviderMain, privateKeyProviderBatch]) {
            try {

                let newToken = await auth().createCustomToken(userId, {
                    randomUUID: randomUUID()
                });

                console.log(newToken);

                const web3auth = new Web3Auth({
                    clientId: config.WEB3AUTH_CLIENT_ID,
                    web3AuthNetwork: config.WEB3AUTH_NETWORK as TORUS_NETWORK_TYPE, // Get your Network ID from Web3Auth Dashboard
                    privateKeyProvider,
                    mode: SDK_MODE.NODE
                });

                await web3auth.init();
                const web3AuthProvider = await web3auth.connect({
                    verifier: config.WEB3AUTH_VERIFIER, // replace with your verifier name
                    verifierId: userId, // replace with your verifier id's value, for example, sub value of JWT Token, or email address.
                    idToken: newToken, // replace with your newly created unused JWT Token.
                });

                privateKey = await web3AuthProvider?.request({ method: "eth_private_key" }) as string;
                break;
            }
            catch (e) {
                logger.error(`Failed to get auth from web3auth for url ${privateKeyProvider.config.chainConfig.rpcTarget}`, e);
                continue;
            }
        }

        if (privateKey == null) {
            throw "Failed to get auth from web3auth";
        }


        let signer = privateKeyToAccount(("0x" + privateKey) as Hex);

        (req.user as any).smartAccountClients = {};

        for (let chain of config.SUPPORTED_CHAINS) {
            const account = await signerToSafeSmartAccount(publicClients[chain.name.toLowerCase()], {
                signer,
                entryPoint: ENTRYPOINT_ADDRESS_V07, // global entrypoint
                safeVersion: "1.4.1",
            });

            logger.debug(`Smart account address for chain ${chain.name.toLowerCase()}: ${account.address}`);

            const smartAccountClient = createSmartAccountClient({
                account,
                chain,
                entryPoint: ENTRYPOINT_ADDRESS_V07,
                bundlerTransport: http(config.CHAIN_CONFIG[chain.name.toLowerCase()].bundler),
                middleware: {
                    sponsorUserOperation: paymasterClients[chain.name.toLowerCase()].sponsorUserOperation, // optional
                    gasPrice: async () => (await pimlicoBundlerClients[chain.name.toLowerCase()].getUserOperationGasPrice()).fast, // if using pimlico bundler
                }
            });
            (req.user as any).smartAccountClients[chain.name.toLowerCase()] = smartAccountClient;
        }

        (req.user as any).stellarKeyPair = await getStellarKeyPair(privateKey);

        next();
    } catch (e) {
        logger.error("Error populating wallets", e);
        throw e;
    }
}

Error Logs:
This is happening for userId: qcI9f2zDGXMhFKxL4HhGyUUher73

[1] Response: 504 Gateway Timeout
[1] Url: https://node-1.dev-node.web3auth.io/sss/jrpc
[1] {"severity":"ERROR","message":"Failed to get auth from web3auth for url https://slivertestnet.duckdns.org Error: Error occurred while getting current epoch\n    at /Users/peeyushaggarwal/Work/new-sliver/sliver-backend/node_modules/@web3auth/single-factor-auth/node_modules/@toruslabs/torus.js/dist/lib.cjs/some.js:83:20\n    at <anonymous>\n    at processTicksAndRejections (node:internal/process/task_queues:105:5)"}

but working for xQpNrpB8c7bRR1OHUSmUQfGnyTT2 and V8muXiqSQMhGXq2LwrFW67P4jfV2. Though I am seeing quite a lot of errors like this but functionality is still workinf.

[1] Response: 504 Gateway Timeout
[1] Url: https://node-1.dev-node.web3auth.io/sss/jrpc

Please any help is appreciated. this is blocking my development.

Thank you for the detailed report, Peeyush! Here’s a summary of your issue for the support team, along with some initial guidance:


Issue Summary

  • SDK: Web3Auth Single Factor Auth (SFA) Node SDK
  • SDK Version: 9.5.0
  • Platform: NodeJS
  • Custom Authentication:
    • Verifier Name: sliver-firebase-auth-test
    • JWKS Endpoint: Google JWKS
    • Sample idToken (JWT): Provided above
  • Code Snippet: Full Web3Auth initialization and login logic provided
  • Error Logs:
    • 504 Gateway Timeout from https://node-1.dev-node.web3auth.io/sss/jrpc
    • Error: Error occurred while getting current epoch
    • Issue is intermittent: fails for some users (e.g., qcI9f2zDGXMhFKxL4HhGyUUher73), works for others (e.g., xQpNrpB8c7bRR1OHUSmUQfGnyTT2)
  • Impact: Blocking development due to frequent timeouts, though some functionality still works.

Next Steps / Suggestions

  1. Intermittent Gateway Timeouts:

    • 504 errors from the SFA node endpoint (/sss/jrpc) suggest possible network issues or rate limiting.
    • Are you seeing any patterns (e.g., specific times, user IDs, or request rates) when failures occur?
    • If possible, try using a different network or environment to rule out local connectivity issues.
  2. Error: “Error occurred while getting current epoch”:

    • This error typically originates from the Torus SSS (Secret Sharing Service) layer. It may indicate a temporary backend issue.
    • If you have not already, try updating to the latest SFA SDK, as recent releases may contain fixes for similar issues: Web3Auth Node SDK Changelog.
  3. Verifier & Token Validity:

    • Double-check that the JWT tokens generated for each user are valid and not expired at the time of use.
    • Ensure the verifier configuration in the Web3Auth dashboard matches your JWT claims and JWKS endpoint.
  4. Retries & Error Handling:

    • Consider implementing a retry mechanism for transient 504 errors, as these may resolve on a subsequent attempt.
  5. Check Service Status:

    • Sometimes, backend service issues can cause these errors. Check Web3Auth Status Page for any ongoing incidents.

Additional Information Requested

  • If you have any logs showing request/response headers for the failing calls, please share them (redact sensitive info).
  • Are there any recent changes in your Web3Auth dashboard configuration or network environment?

Reference Docs


Thank you for your patience. The support team will review this summary and your details to assist further. If you notice any additional patterns or have more logs, feel free to share them here!

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. Web3Auth Developer Office Hours

This was a minor disruption on our sapphire_devnet environment only, the sapphire_mainnet network advised to be used in prod env was stable.
We looked into it and now even the sapphire_devnet is stable. Apologies for the disruption.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.