[flutter_tools] Pause web server requests until initial compilation finishes - #191990
Conversation
56d6dae to
771cb39
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to pause incoming requests to the web asset server until it is fully ready to handle them. It adds a markReady method to WebDevFS and WebAssetServer, and introduces a middleware that awaits this readiness before processing requests. The review feedback highlights a potential race condition in ResidentWebRunner where markReady is called synchronously after connect, potentially unpausing requests before the DWDS connection listener is registered, and suggests waiting for the connection to complete first.
| final Future<ConnectionResult?>? connectDebug = supportsServiceProtocol | ||
| ? webDevFS.connect(useDebugExtension) | ||
| : null; | ||
| webDevFS.markReady(); |
There was a problem hiding this comment.
I can't reason through why this is the right place to call markReady(). What is the signal we're waiting for that tells us the necessary work is done and it is now safe to respond to web requests?
There was a problem hiding this comment.
This is the point where we know compilation is complete and that we're ready to listen for connected applications. I've added a comment here to document why this is the right place to mark the server as ready to accept connections.
771cb39 to
b15326d
Compare
…inishes When launching an application using `flutter run -d web-server`, the HTTP server begins listening as soon as `WebDevFS.create()` starts `WebAssetServer`. However, the application compilation in `_updateDevFS()` has not yet completed. If a client requests the page before compilation finishes, DWDS attempts to read module metadata while `_webMemoryFS.mergedMetadata` is still null. DWDS then injects an empty module list into the bootstrap script and permanently memoizes that 0 modules exist, causing the page to only load `dart_sdk.js` and hang on a blank white screen. Additionally, if the client connects to DWDS before `webDevFS.connect()` starts listening, the `connectedApps` broadcast event is dropped. This adds a readiness completer to `WebAssetServer` and a Shelf middleware to pause incoming requests until initial compilation completes and the DWDS connection listener is attached. Fixes flutter#191957
b15326d to
1ae47a1
Compare
|
autosubmit label was removed for flutter/flutter/191990, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
flutter/flutter@8d8c1aa...c978386 2026-08-30 engine-flutter-autoroll@skia.org Roll Skia from ce359c7fbfe6 to 588b550a4dd8 (1 revision) (flutter/flutter#192040) 2026-08-30 engine-flutter-autoroll@skia.org Roll Skia from 3ae8e3d1e335 to ce359c7fbfe6 (1 revision) (flutter/flutter#192037) 2026-08-30 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from J123CwfDPYyVDpkMl... to o9DikEfRoFyVK3LKD... (flutter/flutter#192031) 2026-08-29 44747303+theprantadutta@users.noreply.github.com Make the AbsorbPointer sample show the difference from IgnorePointer (flutter/flutter#188940) 2026-08-29 engine-flutter-autoroll@skia.org Roll Dart SDK from 391ff83cd1d3 to 76abdf94faa8 (1 revision) (flutter/flutter#192021) 2026-08-29 engine-flutter-autoroll@skia.org Roll Skia from b392fb672d13 to 3ae8e3d1e335 (1 revision) (flutter/flutter#192020) 2026-08-29 engine-flutter-autoroll@skia.org Roll Skia from 0b4249b26b38 to b392fb672d13 (6 revisions) (flutter/flutter#192016) 2026-08-29 97480502+b-luk@users.noreply.github.com Fixes for texture-backed gradients (flutter/flutter#191925) 2026-08-29 engine-flutter-autoroll@skia.org Roll Dart SDK from ae63a6eca3f1 to 391ff83cd1d3 (3 revisions) (flutter/flutter#192010) 2026-08-29 166619967+ik020@users.noreply.github.com Fix Android license detection for cmdline-tools 23.0+ (flutter/flutter#191554) 2026-08-29 bkonyi@google.com [flutter_tools] Pause web server requests until initial compilation finishes (flutter/flutter#191990) 2026-08-28 codefu@google.com fix(workflow): Mac Verify Binaries needs `Linux mac_android_aot_engine` (flutter/flutter#191999) 2026-08-28 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from dDxH8G5cDBP602eyG... to J123CwfDPYyVDpkMl... (flutter/flutter#191984) 2026-08-28 katelovett@google.com Update scheduled workflow for more tasks, add goldctl update (flutter/flutter#191991) 2026-08-28 katelovett@google.com Update no-main-prs to leave a comment (flutter/flutter#191973) 2026-08-28 269567208+reidbaker-agent@users.noreply.github.com [AGP 9.1.0 Migration #4] Replace plugin build-type copy with initWith on public DSL (flutter/flutter#191606) 2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from fe0b9a5261f9 to 0b4249b26b38 (1 revision) (flutter/flutter#191974) 2026-08-28 louisehsu@google.com [UIScene] Migrate dev/benchmarks/macrobenchmarks to UIScene lifecycle (flutter/flutter#191648) 2026-08-28 louisehsu@google.com Uiscene migrate remaining apps (flutter/flutter#191652) 2026-08-28 bkonyi@google.com [tool] Migrate SymbolizeCommand to modular dependency injection (flutter/flutter#190744) 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 bmparr@google.com,stuartmorgan@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
…r#12693) flutter/flutter@8d8c1aa...c978386 2026-08-30 engine-flutter-autoroll@skia.org Roll Skia from ce359c7fbfe6 to 588b550a4dd8 (1 revision) (flutter/flutter#192040) 2026-08-30 engine-flutter-autoroll@skia.org Roll Skia from 3ae8e3d1e335 to ce359c7fbfe6 (1 revision) (flutter/flutter#192037) 2026-08-30 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from J123CwfDPYyVDpkMl... to o9DikEfRoFyVK3LKD... (flutter/flutter#192031) 2026-08-29 44747303+theprantadutta@users.noreply.github.com Make the AbsorbPointer sample show the difference from IgnorePointer (flutter/flutter#188940) 2026-08-29 engine-flutter-autoroll@skia.org Roll Dart SDK from 391ff83cd1d3 to 76abdf94faa8 (1 revision) (flutter/flutter#192021) 2026-08-29 engine-flutter-autoroll@skia.org Roll Skia from b392fb672d13 to 3ae8e3d1e335 (1 revision) (flutter/flutter#192020) 2026-08-29 engine-flutter-autoroll@skia.org Roll Skia from 0b4249b26b38 to b392fb672d13 (6 revisions) (flutter/flutter#192016) 2026-08-29 97480502+b-luk@users.noreply.github.com Fixes for texture-backed gradients (flutter/flutter#191925) 2026-08-29 engine-flutter-autoroll@skia.org Roll Dart SDK from ae63a6eca3f1 to 391ff83cd1d3 (3 revisions) (flutter/flutter#192010) 2026-08-29 166619967+ik020@users.noreply.github.com Fix Android license detection for cmdline-tools 23.0+ (flutter/flutter#191554) 2026-08-29 bkonyi@google.com [flutter_tools] Pause web server requests until initial compilation finishes (flutter/flutter#191990) 2026-08-28 codefu@google.com fix(workflow): Mac Verify Binaries needs `Linux mac_android_aot_engine` (flutter/flutter#191999) 2026-08-28 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from dDxH8G5cDBP602eyG... to J123CwfDPYyVDpkMl... (flutter/flutter#191984) 2026-08-28 katelovett@google.com Update scheduled workflow for more tasks, add goldctl update (flutter/flutter#191991) 2026-08-28 katelovett@google.com Update no-main-prs to leave a comment (flutter/flutter#191973) 2026-08-28 269567208+reidbaker-agent@users.noreply.github.com [AGP 9.1.0 Migration flutter#4] Replace plugin build-type copy with initWith on public DSL (flutter/flutter#191606) 2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from fe0b9a5261f9 to 0b4249b26b38 (1 revision) (flutter/flutter#191974) 2026-08-28 louisehsu@google.com [UIScene] Migrate dev/benchmarks/macrobenchmarks to UIScene lifecycle (flutter/flutter#191648) 2026-08-28 louisehsu@google.com Uiscene migrate remaining apps (flutter/flutter#191652) 2026-08-28 bkonyi@google.com [tool] Migrate SymbolizeCommand to modular dependency injection (flutter/flutter#190744) 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 bmparr@google.com,stuartmorgan@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
…r#12693) flutter/flutter@8d8c1aa...c978386 2026-08-30 engine-flutter-autoroll@skia.org Roll Skia from ce359c7fbfe6 to 588b550a4dd8 (1 revision) (flutter/flutter#192040) 2026-08-30 engine-flutter-autoroll@skia.org Roll Skia from 3ae8e3d1e335 to ce359c7fbfe6 (1 revision) (flutter/flutter#192037) 2026-08-30 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from J123CwfDPYyVDpkMl... to o9DikEfRoFyVK3LKD... (flutter/flutter#192031) 2026-08-29 44747303+theprantadutta@users.noreply.github.com Make the AbsorbPointer sample show the difference from IgnorePointer (flutter/flutter#188940) 2026-08-29 engine-flutter-autoroll@skia.org Roll Dart SDK from 391ff83cd1d3 to 76abdf94faa8 (1 revision) (flutter/flutter#192021) 2026-08-29 engine-flutter-autoroll@skia.org Roll Skia from b392fb672d13 to 3ae8e3d1e335 (1 revision) (flutter/flutter#192020) 2026-08-29 engine-flutter-autoroll@skia.org Roll Skia from 0b4249b26b38 to b392fb672d13 (6 revisions) (flutter/flutter#192016) 2026-08-29 97480502+b-luk@users.noreply.github.com Fixes for texture-backed gradients (flutter/flutter#191925) 2026-08-29 engine-flutter-autoroll@skia.org Roll Dart SDK from ae63a6eca3f1 to 391ff83cd1d3 (3 revisions) (flutter/flutter#192010) 2026-08-29 166619967+ik020@users.noreply.github.com Fix Android license detection for cmdline-tools 23.0+ (flutter/flutter#191554) 2026-08-29 bkonyi@google.com [flutter_tools] Pause web server requests until initial compilation finishes (flutter/flutter#191990) 2026-08-28 codefu@google.com fix(workflow): Mac Verify Binaries needs `Linux mac_android_aot_engine` (flutter/flutter#191999) 2026-08-28 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from dDxH8G5cDBP602eyG... to J123CwfDPYyVDpkMl... (flutter/flutter#191984) 2026-08-28 katelovett@google.com Update scheduled workflow for more tasks, add goldctl update (flutter/flutter#191991) 2026-08-28 katelovett@google.com Update no-main-prs to leave a comment (flutter/flutter#191973) 2026-08-28 269567208+reidbaker-agent@users.noreply.github.com [AGP 9.1.0 Migration flutter#4] Replace plugin build-type copy with initWith on public DSL (flutter/flutter#191606) 2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from fe0b9a5261f9 to 0b4249b26b38 (1 revision) (flutter/flutter#191974) 2026-08-28 louisehsu@google.com [UIScene] Migrate dev/benchmarks/macrobenchmarks to UIScene lifecycle (flutter/flutter#191648) 2026-08-28 louisehsu@google.com Uiscene migrate remaining apps (flutter/flutter#191652) 2026-08-28 bkonyi@google.com [tool] Migrate SymbolizeCommand to modular dependency injection (flutter/flutter#190744) 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 bmparr@google.com,stuartmorgan@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
Description
When launching a web application using
flutter run -d web-server, the HTTP server begins listening as soon asWebDevFS.create()startsWebAssetServer. However, application compilation in_updateDevFS()has not yet completed.If a client requests the page before compilation finishes, DWDS attempts to read module metadata while
_webMemoryFS.mergedMetadatais still null. DWDS then injects an empty module list into the bootstrap script (main_module.bootstrap.js) and permanently memoizes that 0 modules exist inMetadataProvider._metadataMemoizer, causing the page to only loaddart_sdk.jsand hang on a blank white screen. In Chrome console logs, this exhibits asDDC is about to load 1/2 scripts with pool size = 1000with nothing else loading afterwards.Additionally, if the client connects to DWDS before
webDevFS.connect()starts listening, theconnectedAppsbroadcast event is dropped without listeners, causing the tool to hang waiting for a connection.This PR adds a readiness completer to
WebAssetServerand a Shelf middleware to pause incoming HTTP requests until initial compilation completes and the DWDS connection listener is attached.Related Issues
Fixes #191957
Tests
packages/flutter_tools/test/general.shard/web/web_asset_server_test.dartverifying thatisReadycompletes onmarkReady()/dispose()and that incoming HTTP requests are held untilmarkReady()is called.packages/flutter_tools/test/general.shard/resident_web_runner_test.dartverifying thatResidentWebRunner.run()marksWebDevFSas ready before starting the app.