Skip to content

[flutter_tools] Fix widget_preview unawaited async write race condition#187177

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
bkonyi:fix-widget-preview-race
Jun 1, 2026
Merged

[flutter_tools] Fix widget_preview unawaited async write race condition#187177
auto-submit[bot] merged 3 commits into
flutter:masterfrom
bkonyi:fix-widget-preview-race

Conversation

@bkonyi

@bkonyi bkonyi commented May 27, 2026

Copy link
Copy Markdown
Contributor

This PR resolves a deterministic race condition in preview_detector_test_utils.dart. The test helper changeOperation callback is converted to support and properly await FutureOr<void>, ensuring asynchronous package-configuration writes are fully completed before tearDown deletes the temporary workspace directories. This resolves flakiness and unhandled exceptions under high load in both Linux and Mac shards.

Fixes #186136

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 27, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates several test utility functions in preview_detector_test_utils.dart to accept asynchronous operations by changing the changeOperation parameter type from void Function() to FutureOr<void> Function() and awaiting its execution. However, a critical type mismatch remains because waitForChangeDetected still expects a synchronous void Function(), which will cause static analysis or compilation errors.

@bkonyi bkonyi force-pushed the fix-widget-preview-race branch from 3e451c7 to fb546e6 Compare May 27, 2026 16:26
@github-actions github-actions Bot removed the CICD Run CI/CD label May 27, 2026
@bkonyi bkonyi changed the title Fix widget_preview unawaited asynchronous write race condition in tests [flutter_tools] Fix widget_preview unawaited async write race condition May 27, 2026
@bkonyi bkonyi added the CICD Run CI/CD label May 27, 2026

@jtmcdole jtmcdole left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You need to re-target flutter:master

@bkonyi bkonyi changed the base branch from main to master May 27, 2026 17:24
@bkonyi bkonyi added CICD Run CI/CD and removed CICD Run CI/CD labels May 27, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, fb546e6a8728f8426c14b783d4436b64a40543ec, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@github-actions github-actions Bot removed the CICD Run CI/CD label May 27, 2026
@bkonyi bkonyi added the CICD Run CI/CD label May 27, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 28, 2026
@bkonyi bkonyi added CICD Run CI/CD and removed CICD Run CI/CD labels May 28, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 4a0032e5dbb05a1bbdd3e0894352c20582b2a331, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@github-actions github-actions Bot removed the CICD Run CI/CD label May 28, 2026
bkonyi added 3 commits May 28, 2026 18:07
Convert the test helper callbacks inside `preview_detector_test_utils.dart` from synchronous `void Function()` to `FutureOr<void> Function()` and properly `await` their execution. This ensures any background asynchronous package-configuration writes (such as `savePackageConfig` inside LSP/workspace updates) are fully completed before the test completes and the `tearDown` block deletes the temporary workspace directories. This resolves erratic `PathNotFoundException` and unhandled asynchronous exceptions occurring under heavy CI load on Linux and macOS hosts.

Fixes flutter#186136
Fix formatting issues in preview_detector_test_utils.dart which were causing CI failures in the Linux analyze shard.
…t.dart using DartFormatter

Improve the robustness of `preview_code_generator_test.dart` by formatting the expected DtdConnectionInfo string using `DartFormatter` before comparison. This prevents test failures on local machines with shorter temp directory paths that do not trigger line-wrapping in `dart format`.

This matches the formatting applied by `PreviewCodeGenerator.populateDtdConnectionInfo` using the same `DartFormatter`.
@bkonyi bkonyi force-pushed the fix-widget-preview-race branch from d45fa04 to e4287f6 Compare May 28, 2026 18:15
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 28, 2026
@bkonyi bkonyi requested a review from srawlins May 28, 2026 23:44
@bkonyi bkonyi dismissed jtmcdole’s stale review June 1, 2026 16:04

No longer relevant.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 1, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jun 1, 2026
Merged via the queue into flutter:master with commit 35cd15c Jun 1, 2026
165 of 166 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 1, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 2, 2026
flutter/flutter@54e199a...701665b

2026-06-02 engine-flutter-autoroll@skia.org Roll Skia from c97e939eb5c9 to 279b17fe9fc1 (16 revisions) (flutter/flutter#187425)
2026-06-02 bdero@google.com [Flutter GPU] Add block-compressed texture format support (BC, ETC2, ASTC LDR) (flutter/flutter#187281)
2026-06-02 bdero@google.com [Impeller] Allow attaching specific texture mip levels and slices (flutter/flutter#187066)
2026-06-02 bdero@google.com [Impeller] Fix GLES command submission status before context is current (flutter/flutter#187293)
2026-06-02 engine-flutter-autoroll@skia.org Roll Dart SDK from 3cdc25e8ffe9 to d39850bf4a01 (9 revisions) (flutter/flutter#187409)
2026-06-01 jason-simmons@users.noreply.github.com [Impeller] Use glVertexAttribDivisor on GLES3 and glVertexAttribDivisorEXT on GLES2 with the extension (flutter/flutter#187313)
2026-06-01 matt.boetger@gmail.com [Android] Add Javadoc documentation to TextInputChannel (flutter/flutter#186018)
2026-06-01 mvincentong@gmail.com Read FLTEnableWideGamut from Dart bundle (flutter/flutter#186509)
2026-06-01 matt.boetger@gmail.com [flutter_tools] Remove obsolete AndroidX console warning during Gradle builds (flutter/flutter#186077)
2026-06-01 kjlubick@users.noreply.github.com [skia] Update gni file list name hsw -> ml3 (flutter/flutter#184892)
2026-06-01 zhongliu88889@gmail.com [web] Always sync slider input attrs regardless of gesture mode (flutter/flutter#187217)
2026-06-01 zhongliu88889@gmail.com [flutter_driver] Don't throw when stderr is unavailable on web (flutter/flutter#187190)
2026-06-01 116356835+AbdeMohlbi@users.noreply.github.com Remove unused code in `FlutterPluginUtils.kt` (flutter/flutter#187012)
2026-06-01 taak140@gmail.com [flutter_tools] Fix `flutter drive --chrome-binary` being ignored on web (flutter/flutter#185481)
2026-06-01 davidmartos96@gmail.com Eager failure when building and no XCode build settings (flutter/flutter#184726)
2026-06-01 goung123@gmail.com Fix Windows Korean IME caret position during composition (flutter/flutter#186353)
2026-06-01 okorohelijah@google.com iOS: update provisioning profile for 2026-2027 cert (flutter/flutter#187280)
2026-06-01 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#187380)
2026-06-01 jason-simmons@users.noreply.github.com Reland "Move dart-lang/ai to a top level third party dependency in engine (#187268)" (flutter/flutter#187378)
2026-06-01 stuartmorgan@google.com Add vector_math to Framework triage (flutter/flutter#187389)
2026-06-01 engine-flutter-autoroll@skia.org Roll Packages from e930ced to f5d50ca (4 revisions) (flutter/flutter#187381)
2026-06-01 mr_nadeem_iqbal@yahoo.com [flutter_tools] Reject archive entries that escape into a sibling directory by name prefix (#185794) (flutter/flutter#186647)
2026-06-01 bkonyi@google.com [flutter_tools] Fix widget_preview unawaited async write race condition (flutter/flutter#187177)
2026-06-01 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#187375)
2026-06-01 engine-flutter-autoroll@skia.org Roll Skia from 0aee4675e0ad to c97e939eb5c9 (7 revisions) (flutter/flutter#187371)
2026-06-01 mr_nadeem_iqbal@yahoo.com docs: Stack.clipBehavior = Clip.none does not extend hit testing (#160787) (flutter/flutter#186643)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11822)

flutter/flutter@54e199a...701665b

2026-06-02 engine-flutter-autoroll@skia.org Roll Skia from c97e939eb5c9 to 279b17fe9fc1 (16 revisions) (flutter/flutter#187425)
2026-06-02 bdero@google.com [Flutter GPU] Add block-compressed texture format support (BC, ETC2, ASTC LDR) (flutter/flutter#187281)
2026-06-02 bdero@google.com [Impeller] Allow attaching specific texture mip levels and slices (flutter/flutter#187066)
2026-06-02 bdero@google.com [Impeller] Fix GLES command submission status before context is current (flutter/flutter#187293)
2026-06-02 engine-flutter-autoroll@skia.org Roll Dart SDK from 3cdc25e8ffe9 to d39850bf4a01 (9 revisions) (flutter/flutter#187409)
2026-06-01 jason-simmons@users.noreply.github.com [Impeller] Use glVertexAttribDivisor on GLES3 and glVertexAttribDivisorEXT on GLES2 with the extension (flutter/flutter#187313)
2026-06-01 matt.boetger@gmail.com [Android] Add Javadoc documentation to TextInputChannel (flutter/flutter#186018)
2026-06-01 mvincentong@gmail.com Read FLTEnableWideGamut from Dart bundle (flutter/flutter#186509)
2026-06-01 matt.boetger@gmail.com [flutter_tools] Remove obsolete AndroidX console warning during Gradle builds (flutter/flutter#186077)
2026-06-01 kjlubick@users.noreply.github.com [skia] Update gni file list name hsw -> ml3 (flutter/flutter#184892)
2026-06-01 zhongliu88889@gmail.com [web] Always sync slider input attrs regardless of gesture mode (flutter/flutter#187217)
2026-06-01 zhongliu88889@gmail.com [flutter_driver] Don't throw when stderr is unavailable on web (flutter/flutter#187190)
2026-06-01 116356835+AbdeMohlbi@users.noreply.github.com Remove unused code in `FlutterPluginUtils.kt` (flutter/flutter#187012)
2026-06-01 taak140@gmail.com [flutter_tools] Fix `flutter drive --chrome-binary` being ignored on web (flutter/flutter#185481)
2026-06-01 davidmartos96@gmail.com Eager failure when building and no XCode build settings (flutter/flutter#184726)
2026-06-01 goung123@gmail.com Fix Windows Korean IME caret position during composition (flutter/flutter#186353)
2026-06-01 okorohelijah@google.com iOS: update provisioning profile for 2026-2027 cert (flutter/flutter#187280)
2026-06-01 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#187380)
2026-06-01 jason-simmons@users.noreply.github.com Reland "Move dart-lang/ai to a top level third party dependency in engine (#187268)" (flutter/flutter#187378)
2026-06-01 stuartmorgan@google.com Add vector_math to Framework triage (flutter/flutter#187389)
2026-06-01 engine-flutter-autoroll@skia.org Roll Packages from e930ced to f5d50ca (4 revisions) (flutter/flutter#187381)
2026-06-01 mr_nadeem_iqbal@yahoo.com [flutter_tools] Reject archive entries that escape into a sibling directory by name prefix (#185794) (flutter/flutter#186647)
2026-06-01 bkonyi@google.com [flutter_tools] Fix widget_preview unawaited async write race condition (flutter/flutter#187177)
2026-06-01 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#187375)
2026-06-01 engine-flutter-autoroll@skia.org Roll Skia from 0aee4675e0ad to c97e939eb5c9 (7 revisions) (flutter/flutter#187371)
2026-06-01 mr_nadeem_iqbal@yahoo.com docs: Stack.clipBehavior = Clip.none does not extend hit testing (#160787) (flutter/flutter#186643)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
…on (flutter#187177)

This PR resolves a deterministic race condition in
`preview_detector_test_utils.dart`. The test helper `changeOperation`
callback is converted to support and properly `await` `FutureOr<void>`,
ensuring asynchronous package-configuration writes are fully completed
before `tearDown` deletes the temporary workspace directories. This
resolves flakiness and unhandled exceptions under high load in both
Linux and Mac shards.

Fixes flutter#186136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux tool_tests_commands is 2.00% flaky

4 participants