Skip to content

CachingAssetBundle.loadStructuredData is not forwarding rejection in loadString to returned future. #42390

@nandin-borjigin

Description

@nandin-borjigin

If you call rootBundle.loadStructuredData with a non-existing asset key, it would throw an Unhandled Exception. And you can't catch it by any means (Future.catchError, try await catch etc).

This is because this line does not catch that error and forward it to the returning future.

Steps to Reproduce

main() {
  final String foo = rootBundle.loadStructuredData(
    'some/asset/that/does/not/exists.json', 
    (str) => str
  ).catchError((e) {
    print(e);
    return 'Nothing';
  });

Target Platform: iOS
Target OS version/browser: 13.1
Devices: iOS Simulator (iPhone 11 Pro Max 13.1)

Logs

Too verbose but nothing relavant.
Analyzing app...
No issues found! (ran in 3.2s)
[✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Mac OS X 10.14.6 18G87, locale en-CN)
    • Flutter version 1.9.1+hotfix.2 at /Users/hashfuture/.flutter-sdk
    • Framework revision 2d2a1ffec9 (5 weeks ago), 2019-09-06 18:39:49 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/hashfuture/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.1, Build version 11A1027
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.38.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • 6D61E69B-49E2-40BD-B3B6-905EAAE6519A • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-1 (simulator)

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: assetsPackaging, accessing, or using assetsfound in release: 1.22Found to occur in 1.22found in release: 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions