react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.7k stars 466 forks source link

Navigation freeze after using multiGet function #984

Closed ravindraguptacapgemini closed 1 year ago

ravindraguptacapgemini commented 1 year ago

What happened?

We tried using latest version 1.19.0, and observed that things those were working fine earlier are now breaking with newer version.

Just pasting the code snippet here

class InitialScreen extends Component {

componentDidMount() {
  tryLoginUsingOauth()
}

 async tryLoginUsingOauth() {
    try {
      const stores = await this.multiGetFromAsyncStorage(['server', 'username']);

      const { server, username } = R.fromPairs(stores); // R for Ramda

      if (!server || !username || !realmUrl) {
        this.goToLoginScreen();

        return;
      }
   } catch (err) {
      this.goToLoginScreen();
    }
}

multiGetFromAsyncStorage(items) {
    return new Promise((resolve, reject) => {
      AsyncStorage.multiGet(items, (err, stores) => {
        if (err) {
          reject(err);
          return;
        }

        resolve(stores);
      });
    });
  }

  goToLoginScreen() {
    navigation.navigate(route.name);
   }
}

Version

1.19.0

What platforms are you seeing this issue on?

System Information

System:
  OS: macOS 13.4
  CPU: (12) arm64 Apple M2 Pro
  Memory: 1.53 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 16.20.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 8.19.4
    path: /usr/local/bin/npm
  Watchman:
    version: 2023.06.26.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/ravindragupta/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.2 AI-222.4459.24.2221.10121639
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.19
    path: /usr/bin/javac
  Ruby:
    version: 3.0.4
    path: /Users/ravindragupta/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 11.3.5
    wanted: ^11.3.4
  react:
    installed: 18.2.0
    wanted: ^18.2.0
  react-native:
    installed: 0.72.1
    wanted: 0.72.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: true
iOS:
  hermesEnabled: false
  newArchEnabled: true

Steps to Reproduce

Use multiget function and update navigation just after that call.

krizzu commented 1 year ago

Hey, Do you see any iOS crashes?

ravindraguptacapgemini commented 1 year ago

@krizzu I don't see a crash actually, but seems like it's affecting the UI thread or something.

github-actions[bot] commented 1 year ago

This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.