Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MagicSDK stopped working since yesterday: MODAL_NOT_READY or network timeout #672

Closed
3 tasks done
pax-k opened this issue Nov 22, 2023 · 1 comment ยท Fixed by #673
Closed
3 tasks done

MagicSDK stopped working since yesterday: MODAL_NOT_READY or network timeout #672

pax-k opened this issue Nov 22, 2023 · 1 comment ยท Fixed by #673

Comments

@pax-k
Copy link

pax-k commented Nov 22, 2023

โœ… Prerequisites

  • Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
  • Are you running the latest SDK version?
  • Are you reporting to the correct repository (magic-sdk)?

๐Ÿ› Description

When trying to call const isMagicLoggedIn = await magic.user.isLoggedIn();, I either get this error: Magic SDK Error: [MODAL_NOT_READY] Modal is not ready., either the await never gets resolved.

๐Ÿงฉ Steps to Reproduce

Install the below documented dependencies and run the code sample.

๐Ÿค” Expected behavior

I expect no error or timeouts.

๐Ÿ˜ฎ Actual behavior

I receive MODAL_NOT_READY or the await call never gets resolved.

๐Ÿ’ป Code Sample

import { Magic, useInternetConnection } from '@magic-sdk/react-native-expo';
import { useEffect, useState } from 'react';

export const MagicAuth = ({ children, apiKey }) => {
  const [magic, setMagic] = useState<Magic | null>(null);
  const connected = useInternetConnection();

  const checkAuth = async () => {
    if (magic === null) return;
    const isMagicLoggedIn = await magic.user.isLoggedIn(); // this either triggers MODAL_NOT_READY error, either the await never resolves
    console.log('isMagicLoggedIn', isMagicLoggedIn);
  };

  useEffect(() => {
    const magic = new Magic(apiKey);
    setMagic(magic);
  }, []);

  useEffect(() => {
    if (magic && connected) checkAuth();
  }, [magic, connected]);


  return (
    <>
      {magic !== null && connected ? <magic.Relayer /> : null}
    </>
  );
};

๐ŸŒŽ Environment

  • yarn
"react-native": "0.72.6",
"expo": "^49.0.11",
"@magic-sdk/react-native-expo": "22.3.0",
"@react-native-community/netinfo": "11.1.0",
@VirenMohindra
Copy link

Facing the same issue. Our fix is to retry magic.user.isLoggedIn(). It shows up the second time round.

  const checkIfLoggedIn = async () => {
    try {
      const isLoggedIn = await magic.user.isLoggedIn()
      if (!isLoggedIn) await logout()
    } catch (e) {
      console.log('error', e)
    }
  }
"react-native": "0.72.6",
"expo": "~49.0.13",
"@magic-sdk/react-native-expo": "^22.0.0",

we did not install netinfo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment