-
Notifications
You must be signed in to change notification settings - Fork 6k
ensure _futurize does not leak uncaught errors into the zone #32070
ensure _futurize does not leak uncaught errors into the zone #32070
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Gold has detected about 5 new digest(s) on patchset 2. |
|
Gold has detected about 18 new digest(s) on patchset 3. |
|
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. |
|
Gold has detected about 18 new digest(s) on patchset 4. |
|
I am ... extremely confused on how this is changing web goldens. |
|
Golden file changes are available for triage from new commit, Click here to view. |
|
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
Gold has detected about 18 new digest(s) on patchset 7. |
|
Do I need to do anything else to satisfy the gold bot? |
No, you're good. |
* 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)
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