vivaxy/react-native-auto-height-image

[Unhandled promise rejection: Error: Failed to getSize of ...]

staghouse opened this issue · 3 comments

Describe the bug

It seems the error handling is not working. When using a failing URI, I get thrown a warning:

[Unhandled promise rejection: Error: Failed to getSize of ...] where ... is the URI

The onError prop never fires either.

Expected behavior
The onError callback should fire and there should not be an unhandled promise.

Additional context/Dependencies
I'm using Expo, here is my diagnostics:

  Expo CLI 3.28.0 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.18.4 - /usr/local/bin/node
      Yarn: 1.22.5 - /usr/local/bin/yarn
      npm: 6.14.6 - /usr/local/bin/npm
    Managers:
      CocoaPods: 1.9.3 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
      Android SDK:
        API Levels: 28
        Build Tools: 28.0.3
    IDEs:
      Android Studio: 4.1 AI-201.8743.12.41.6858069
      Xcode: 12.0.1/12A7300 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~39.0.2 => 39.0.3 
      react: 16.13.1 => 16.13.1 
      react-dom: 16.13.1 => 16.13.1 
      react-native: https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz => 0.63.2 
      react-native-web: ~0.13.12 => 0.13.15 
    npmGlobalPackages:
      expo-cli: 3.27.13
    Expo Workflow: managed

I think maybe it's because async function in useEffect is not handling the error.

Is it possible that the reject from the cache file is not helping either?

Just wrapping that async useEffect in a try/catch does nothing but catch the same error that propogating from the getSize function

@staghouse I've tested, wrapping that async useEffect in a try/catch fix this unhandled promise rejection. Please try 3.2.3.