Repository navigation
CachingAssetBundle.loadStructuredData is not forwarding rejection in loadString to returned future. #42390
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: assetsPackaging, accessing, or using assetsPackaging, accessing, or using assetsfound in release: 1.22Found to occur in 1.22Found to occur in 1.22found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight
Description
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!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: assetsPackaging, accessing, or using assetsPackaging, accessing, or using assetsfound in release: 1.22Found to occur in 1.22Found to occur in 1.22found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight
Activity
[-]`CachedAssetBundle.loadStructuredData` is not forwarding rejection in `loadString` to returned future.[/-][+]`CachingAssetBundle.loadStructuredData` is not forwarding rejection in `loadString` to returned future.[/+]markusaksli-nc commentedon Sep 25, 2020
Reproducible on the latest master
1.22.0-10.0.pre.340.flutter doctor -v
Updated sample
Should be an easy enough fix, if someone wants to work on this I'd suggest taking a look at the previous attempt that ran into a few test failures first #42394.
nandin-borjigin commentedon Sep 30, 2020
Hi @markusaksli-nc, I'm willing to continue my previous effort to fix this.
Can you help me with this error in CI? It seems like my forked project's CI machine needs an access to a private repo.
markusaksli-nc commentedon Oct 1, 2020
Not exactly sure what that could be about. Have you tried asking the hackers channel on discord?
nandin-borjigin commentedon Oct 5, 2020
I can't find a hackers channel under /r/FlutterDev
markusaksli-nc commentedon Oct 5, 2020
@Nandiin That's the community discord, see Chat for a link to the contributors discord.
maheshj01 commentedon Nov 24, 2022
I can reproduce the issue with or without
try catchin the below code sample the exception cannot be caught.code sample
logs
flutter doctor -v (mac)
Catch errors in loadStructuredData (#130748)
Catch errors in loadStructuredData (flutter#130748)
github-actions commentedon Aug 2, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.