Skip to content

async* inconsistency in DDC #54411

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

Closed
sigmundch opened this issue Dec 19, 2023 · 6 comments
Closed

async* inconsistency in DDC #54411

sigmundch opened this issue Dec 19, 2023 · 6 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. dev-compiler-async web-dev-compiler

Comments

@sigmundch
Copy link
Member

We know we have several inconsistencies so far, here is a case originally reported in the flutter repo: flutter/flutter#140199

import 'dart:async';

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()) {
      print('v: $v');
    }
  } catch (e) {
    print('e: $e');
  }
  print('finish');
}

Output in VM and dart2js:

v: 0
v: 1
e: Exception: error
finish

Output in DDC:

v: 0
v: 1
@nietsmmar
Copy link

Is there any progress on this? I find it quite difficult to debug my applications with this wrong behavior in dev build.
Thanks :)

@nietsmmar
Copy link

@sigmundch are there any updates on this?

@sigmundch
Copy link
Member Author

Thanks for following up, unfortunately no, we haven't been able to prioritize this 😞

This may not be very helpful or you may already be aware of this, but just in case: some developers find useful to do some additional debugging with the --profile mode. That mode runs the dart2js compiler (same one use for release builds) in a mode that keeps around the original names of your classes and members. That compiler will have the correct async* semantics. However, it can only be used with the default browser devtools and not via the Dart Devtools. Anyways, sometimes it can provide a bit of additional info that it's otherwise hard to get in other ways today.

@nshahan
Copy link
Contributor

nshahan commented Jul 30, 2024

@natebiggs
I believe this has been corrected with your change. WDYT?

@biggs0125
Copy link

I just verified locally that DDC, with the new async changes, now shows an output aligned with the VM and dart2js. These changes should roll into Flutter soon but likely won't be in a stable release for a few months. Going to close out this issue though as the fix has been landed in the Dart SDK.

@sigmundch
Copy link
Member Author

Just wondering, is it safe to assume the current test coverage also covers this case, or is it worth adding it as a regression test case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. dev-compiler-async web-dev-compiler
Projects
None yet
Development

No branches or pull requests

5 participants