Skip to content

[flutter_tools] Safely remove web loading indicator on dart-app-ready - #192233

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
bkonyi:fix-web-loader-removechild-192226
Sep 8, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
bkonyi:fix-web-loader-removechild-192226

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #192226

Problem

In packages/flutter_tools/lib/src/web/bootstrap.dart, when compiling the web bootstrap script (main.dart.js), an event listener was added to window for dart-app-ready that executed:

loader.parentNode.removeChild(loader);

On initial load, this removes the loader from the DOM, setting loader.parentNode to null.
When DWDS reconnects or re-dispatches dart-app-ready (e.g. following a WebSocket disconnect/reconnect), this listener was invoked again. Attempting to call .removeChild on a null parentNode threw:

TypeError: Cannot read properties of null (reading 'removeChild')

Solution

  1. Use loader.remove() and styleSheet.remove() instead of parentNode.removeChild().
  2. Configure the event listener with { once: true } so it is automatically removed after firing once.

Tests

Added regression unit tests to packages/flutter_tools/test/general.shard/web/bootstrap_test.dart verifying that { once: true } and .remove() are used in generated web bootstrap code.

When the debug WebSocket connection temporarily drops and reconnects,
DWDS dispatches a subsequent 'dart-app-ready' event. Previously, the event
listener in the bootstrapping script directly called
`loader.parentNode.removeChild(loader)`, which caused an unhandled TypeError
("Cannot read properties of null (reading 'removeChild')") on subsequent
events because the loader had already been detached.

Configure the 'dart-app-ready' event listener with `{ once: true }` so it
runs at most once, and use `loader.remove()` and `styleSheet.remove()` to safely
remove the elements without relying on `parentNode`.

Fixes flutter#192226
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 3, 2026
@bkonyi
bkonyi requested a review from Markzipan September 3, 2026 19:48
@bkonyi
bkonyi marked this pull request as ready for review September 3, 2026 19:48
@bkonyi bkonyi added the CICD Run CI/CD label Sep 3, 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 the web bootstrap script generation to use Element.remove() instead of parentNode.removeChild() for removing the loader and stylesheet elements, and configures the 'dart-app-ready' event listener to trigger only once by passing the { once: true } option. Corresponding unit tests have been added to verify these changes. I have no feedback to provide.

@goderbauer goderbauer 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.

LGTM

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 8, 2026
Merged via the queue into flutter:master with commit 78ca392 Sep 8, 2026
30 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 8, 2026
flutter/flutter@63170e9...b444e78

2026-09-08 [email protected] Clean up lint errors in workflows (flutter/flutter#191987)
2026-09-08 [email protected] Remove no-shuffle tag from dropdown_test.dart (flutter/flutter#186398)
2026-09-08 [email protected] Remove no-shuffle from scrollbar test (flutter/flutter#186656)
2026-09-08 [email protected] [tool] Let --local-engine reach the build system again (flutter/flutter#192361)
2026-09-08 [email protected] [flutter_tools] Safely remove web loading indicator on dart-app-ready (flutter/flutter#192233)
2026-09-08 [email protected] [Linux] Don't clear the OpenGL context when a frame has been drawn (flutter/flutter#192137)
2026-09-08 [email protected] ci: update dartdoc from 9.0.6 to 9.0.9 (flutter/flutter#192405)
2026-09-07 [email protected] Add itemExtentBuilder support to ListView.separated (flutter/flutter#191157)
2026-09-07 [email protected] Roll Skia from e1437642d259 to b3fa80a0e168 (5 revisions) (flutter/flutter#192362)
2026-09-07 [email protected] Roll Skia from 2df865d9d369 to e1437642d259 (1 revision) (flutter/flutter#192360)
2026-09-07 [email protected] Roll Skia from c7aa5512d148 to 2df865d9d369 (2 revisions) (flutter/flutter#192357)
2026-09-06 [email protected] Roll Skia from db200e27a634 to c7aa5512d148 (2 revisions) (flutter/flutter#192351)
2026-09-06 [email protected] Roll Fuchsia Linux SDK from _IgixhH4vEgdz9Oqn... to p8hHkUi8uWT9R3N4z... (flutter/flutter#192349)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] 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
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12791)

flutter/flutter@63170e9...b444e78

2026-09-08 [email protected] Clean up lint errors in workflows (flutter/flutter#191987)
2026-09-08 [email protected] Remove no-shuffle tag from dropdown_test.dart (flutter/flutter#186398)
2026-09-08 [email protected] Remove no-shuffle from scrollbar test (flutter/flutter#186656)
2026-09-08 [email protected] [tool] Let --local-engine reach the build system again (flutter/flutter#192361)
2026-09-08 [email protected] [flutter_tools] Safely remove web loading indicator on dart-app-ready (flutter/flutter#192233)
2026-09-08 [email protected] [Linux] Don't clear the OpenGL context when a frame has been drawn (flutter/flutter#192137)
2026-09-08 [email protected] ci: update dartdoc from 9.0.6 to 9.0.9 (flutter/flutter#192405)
2026-09-07 [email protected] Add itemExtentBuilder support to ListView.separated (flutter/flutter#191157)
2026-09-07 [email protected] Roll Skia from e1437642d259 to b3fa80a0e168 (5 revisions) (flutter/flutter#192362)
2026-09-07 [email protected] Roll Skia from 2df865d9d369 to e1437642d259 (1 revision) (flutter/flutter#192360)
2026-09-07 [email protected] Roll Skia from c7aa5512d148 to 2df865d9d369 (2 revisions) (flutter/flutter#192357)
2026-09-06 [email protected] Roll Skia from db200e27a634 to c7aa5512d148 (2 revisions) (flutter/flutter#192351)
2026-09-06 [email protected] Roll Fuchsia Linux SDK from _IgixhH4vEgdz9Oqn... to p8hHkUi8uWT9R3N4z... (flutter/flutter#192349)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] 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
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12791)

flutter/flutter@63170e9...b444e78

2026-09-08 [email protected] Clean up lint errors in workflows (flutter/flutter#191987)
2026-09-08 [email protected] Remove no-shuffle tag from dropdown_test.dart (flutter/flutter#186398)
2026-09-08 [email protected] Remove no-shuffle from scrollbar test (flutter/flutter#186656)
2026-09-08 [email protected] [tool] Let --local-engine reach the build system again (flutter/flutter#192361)
2026-09-08 [email protected] [flutter_tools] Safely remove web loading indicator on dart-app-ready (flutter/flutter#192233)
2026-09-08 [email protected] [Linux] Don't clear the OpenGL context when a frame has been drawn (flutter/flutter#192137)
2026-09-08 [email protected] ci: update dartdoc from 9.0.6 to 9.0.9 (flutter/flutter#192405)
2026-09-07 [email protected] Add itemExtentBuilder support to ListView.separated (flutter/flutter#191157)
2026-09-07 [email protected] Roll Skia from e1437642d259 to b3fa80a0e168 (5 revisions) (flutter/flutter#192362)
2026-09-07 [email protected] Roll Skia from 2df865d9d369 to e1437642d259 (1 revision) (flutter/flutter#192360)
2026-09-07 [email protected] Roll Skia from c7aa5512d148 to 2df865d9d369 (2 revisions) (flutter/flutter#192357)
2026-09-06 [email protected] Roll Skia from db200e27a634 to c7aa5512d148 (2 revisions) (flutter/flutter#192351)
2026-09-06 [email protected] Roll Fuchsia Linux SDK from _IgixhH4vEgdz9Oqn... to p8hHkUi8uWT9R3N4z... (flutter/flutter#192349)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] 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
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.

"Cannot read properties of null (reading 'removeChild')" during flutter run

2 participants