Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Mar 16, 2022

Because this is a private function, and because I don't see any tests that use the part of trick to test private functions, I cheated a bit by creating a copy.

Explanation:

When you add an error to a completer, the completer first checks if it has a listener or not. if there is a listener (either from the future or from async/await) then the error is forwarded there. If there is no listener then the error is forwarded to the current Zone's uncaught exception handler.

sync Completers and async Completers work the same in this regard, but async completers always check for a listener in a later microtask whereas a sync Completer will check as soon as it is completed. This means that for a function which immediately/synchronously errors, the Completer may check for a listener before the function has returned - and before the caller has had a chance to add a listener

To fix this, we check in the body of the callback if the function has progressed passed the callback invocation. If it has not, then we know the caller has not added a listener yet and we must synchronously throw an error. If we have passed the body, then the caller will have already added a listener and we can forward the error to the Completer

For a demonstration see https://dartpad.dev/?id=eebd0a2bba7d88d0e9969a68b4bc4a59

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Mar 16, 2022
@flutter-dashboard

This comment was marked as off-topic.

@skia-gold
Copy link

Gold has detected about 5 new digest(s) on patchset 2.
View them at https://flutter-engine-gold.skia.org/cl/github/32070

@skia-gold
Copy link

Gold has detected about 18 new digest(s) on patchset 3.
View them at https://flutter-engine-gold.skia.org/cl/github/32070

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #32070 at sha 667bd19

@skia-gold
Copy link

Gold has detected about 18 new digest(s) on patchset 4.
View them at https://flutter-engine-gold.skia.org/cl/github/32070

@jonahwilliams
Copy link
Contributor Author

I am ... extremely confused on how this is changing web goldens.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #32070 at sha 48b38d7

@jonahwilliams
Copy link
Contributor Author

From discussion on discord, the web goldens are having issues unrelated and we just approve them for now

expectEquals(frameNumber, 2);
});

test('_futureize does not leak sync uncaught exceptions into the zone', () async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going through the trouble of maintaining an additional copy of _futurize, we should try to get more than one unit test out of the bargain. This test covers one of three error pathways, and there is also the success pathway, as examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@skia-gold
Copy link

Gold has detected about 18 new digest(s) on patchset 7.
View them at https://flutter-engine-gold.skia.org/cl/github/32070

@jonahwilliams
Copy link
Contributor Author

Do I need to do anything else to satisfy the gold bot?

@zanderso
Copy link
Member

Do I need to do anything else to satisfy the gold bot?

No, you're good.

@jonahwilliams jonahwilliams added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Mar 17, 2022
@fluttergithubbot fluttergithubbot merged commit e4056c5 into flutter:main Mar 17, 2022
@jonahwilliams jonahwilliams deleted the image_decode_async branch March 17, 2022 18:43
zanderso pushed a commit to flutter/flutter that referenced this pull request Mar 17, 2022
* 7fe613a Roll Dart SDK from 5bc905e69609 to ad5a250935d5 (4 revisions) (flutter/engine#32079)

* 3a954ba Disable several tests due to flakiness (flutter/engine#32059)

* 05bba9b [web] Log all goldctl commands (flutter/engine#32072)

* 86b2c8d Roll Skia from 9301fe3779bb to 02ebd1a23381 (4 revisions) (flutter/engine#32067)

* abb1bce Roll Fuchsia Linux SDK from mVqiTwaVa... to RAyopISUl... (flutter/engine#32069)

* 481f4bc Roll Fuchsia Mac SDK from vWlaMIVkM... to -JEG0j8mn... (flutter/engine#32077)

* 560243c Roll Dart SDK from ad5a250935d5 to 5168cdd236a0 (1 revision) (flutter/engine#32081)

* e2e6b49 Roll Skia from 02ebd1a23381 to 5e035c66da3c (19 revisions) (flutter/engine#32082)

* e4056c5 ensure _futurize does not leak uncaught errors into the zone (flutter/engine#32070)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

platform-web Code specifically for the web engine waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. will affect goldens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants