-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Unable to catch exceptions occurring within async* function returning a Stream in Web(Flutter for Web, DartPad). #140199
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
Comments
Hi @eaglesakura. |
Thanks, @dam-ease . Sample(with UI)import 'package:flutter/material.dart';
Future main() async {
Stream<int> step1() async* {
yield 0;
await Future.delayed(const Duration(milliseconds: 100));
yield 1;
throw Exception('error');
}
Stream<int> step2() async* {
await for (final v in step1()) {
yield v;
}
}
try {
await for (final v in step2()) {
debugPrint('v: $v');
}
} catch (e) {
debugPrint('e: $e');
}
debugPrint('finish, start app!');
runApp(
MaterialApp(
title: 'Sample',
theme: ThemeData.light(),
home: const Scaffold(
body: Center(
child: Text(
'Hello, World!',
),
),
),
),
);
}
Console LogRun on Chrome(VSCode / Debug Build):
Run On Android(VSCode / Debug Build)
Flutter Doctor output
|
Thanks for your response. Deleting this line as in steps import 'package:flutter/material.dart'; // <- delete this Line.
The issue still occurs on flutter web but doesn't with DartPad. flutter doctor -v
|
cc @nshahan DDC discrepancy? |
Correct! Makes sense based on the fact that dartpad with a flutter import uses DDC and without uses dart2js. I confirmed locally and filed dart-lang/sdk#54411 to track on our end. |
Closing in favor of the Dart SDK issue. |
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 |
Uh oh!
There was an error while loading. Please reload this page.
Steps to reproduce
import 'package:flutter/material.dart';
Expected results
Console Log
Before(sample code)
After(delete
import 'package:flutter/material.dart';
)Actual results
Executing the provided code in DartPad results in freezing instead of handling the thrown exception gracefully, unlike other non-web Dart environments, where the exception is appropriately logged.
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[Paste your output here]
The text was updated successfully, but these errors were encountered: