Skip to content

Use a new future instead of a cached future from another zone #831

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

Merged
merged 2 commits into from
May 11, 2018

Conversation

Hixie
Copy link
Contributor

@Hixie Hixie commented May 9, 2018

As far as I can tell the comment doesn't make sense -- you don't pay the microtask hit unless you await the future.

Fixes #830

As far as I can tell the comment doesn't make sense -- you don't pay the microtask hit unless you await the future.

Fixes dart-lang#830
@Hixie
Copy link
Contributor Author

Hixie commented May 9, 2018

Interestingly, it was added in #546 which suggests that this might be needed to not break Flutter in some other way. So maybe this PR is not a good fix for the zone bug.

@natebosch
Copy link
Member

@Hixie - here's the original thread with a link to a Travis failure that I believe is the issue _emptyFuture was intended to solve.

Can you confirm whether this change causes a similar problem?

@grouma
Copy link
Member

grouma commented May 9, 2018

This sounds related to dart-lang/sdk#32556

We had to do a hacky work around here: #787 Can the same approach apply?

@natebosch
Copy link
Member

Another pattern I'd be curious to try:

_emptyCallback() {}
final _emptyFuture = new Future.sync(_emptyCallback):

@tvolkert
Copy link
Contributor

tvolkert commented May 9, 2018

afaik, Future.sync() just delegates to Future.value() under the hood...

@tvolkert
Copy link
Contributor

tvolkert commented May 9, 2018

here's the original thread with a link to a Travis failure

Can you post the link?

@natebosch
Copy link
Member

Can you post the link?

😳

#529 (comment)

@tvolkert
Copy link
Contributor

tvolkert commented May 9, 2018

@tvolkert
Copy link
Contributor

tvolkert commented May 9, 2018

Ok, in flutter/flutter#17415, I've created a test that:

  1. fails without this PR
  2. passes with this PR

Further, I've verified that this PR does not regress system_chrome_test.dart.

tldr: this fix LGTM

@kevmoo kevmoo requested a review from grouma May 9, 2018 06:45
@natebosch
Copy link
Member

@grouma can you confirm that the quiver tests and package:fake_async tests also still pass with this change? I would only expect this to make things better for those packages, not worse, but we should double check.

@Hixie
Copy link
Contributor Author

Hixie commented May 9, 2018

(I don't have commit rights in this repo, so when this is ready to land, please feel free to land it. :-) Thanks!)

@grouma
Copy link
Member

grouma commented May 9, 2018

@natebosch
Copy link
Member

natebosch commented May 9, 2018

Two other possibilities to try:

  • final _emptyFuture = new Future.value()..then((_) {});
  • Return null instead of a future and default it from expectLater.

@grouma
Copy link
Member

grouma commented May 9, 2018

Note that nbosch@ meant:
final _emptyFuture = new Future.value()..then((_) {});
I have confirmed that all tests pass in each package with either option. I'm having a difficult time confirming that either approach resolves the test in flutter/flutter#17415. I'm not sure how to do a dependency override for the flutter_test tests. @tvolkert or @Hixie can you confirm that either approach resolves your issue?

@tvolkert
Copy link
Contributor

tvolkert commented May 9, 2018

@grouma adding a dependency override at the bottom of https://github.com/flutter/flutter/blob/master/packages/flutter_test/pubspec.yaml#L77 was working for me yesterday - does it work for you?

(you'll need to run flutter packages upgrade after you add it)

@grouma
Copy link
Member

grouma commented May 10, 2018

Ran a bunch of tests with the various options. The only thing that passes for all tests in package:async, package:quiver and package:flutter_test is return new Future.sync(() {});. I guess Future.value isn't equivalent.

@grouma grouma merged commit 73ff2f7 into dart-lang:master May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants