You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
Unfortunately, there is no framework specific way to fix this, as we can't force to run this synchronously, but the rest of the framework expects it to be (and users do too)! A couple of ideas:
Change the signature of all the lifecycle events to void to disallow async (BREAKING)
Warn in the compilation process if we notice an async function.
Internally await asynchronous lifecycle events.
Add new lifecycle events that support async setup/teardown.
Unfortunately, (1) is outside of our immediate control, and (2) and (3) would prevent folks from using the async/await syntax in lifecycle methods, which is desirable to some. (4) would fix the usability of the issue, at the expense of making the currently synchronous change detection much more complicated and async, which is also not desirable.
I'm not 100% sure how (5) would work without usability issues.
The text was updated successfully, but these errors were encountered:
Currently that (the void returning async function) will be a strong mode error, but the take away from the discussion in dart-lang/sdk#31324 (comment) was that it shouldn't be.
@matanlurey Yes, that was my takeaway from the discussion in #31324. As I said there, I don't feel like I have strong arguments for or against it, and @lrhn seems to feel that it's useful. Happy to hear more feedback about it.
We have changed the behavior for Dart 2, so async functions start running immediately, up to the first await. We did that exactly because of issues like this (someone changing a sync function to async would be surprised by the initial check not being done immediately, I've caught a few race conditions like that in reviews).
I believe @floitschG is still working on implementing that and updating existing code.
A lot of subtle bug across change detection have been narrowed down to the following:
DartPad.
Expected Behavior
Actual Behavior
Discussion
Unfortunately, there is no framework specific way to fix this, as we can't force to run this synchronously, but the rest of the framework expects it to be (and users do too)! A couple of ideas:
Meta-issue for discussion of the proposal to make
async
functions start synchronously dart-lang/sdk#30345 - nothing has happened here yet we can use.void
to disallowasync
(BREAKING)async
function.Unfortunately, (1) is outside of our immediate control, and (2) and (3) would prevent folks from using the
async/await
syntax in lifecycle methods, which is desirable to some. (4) would fix the usability of the issue, at the expense of making the currently synchronous change detection much more complicated and async, which is also not desirable.I'm not 100% sure how (5) would work without usability issues.
The text was updated successfully, but these errors were encountered: