Skip to content

flutter test --platform chrome can hang after tests pass: Browser.close has no timeout #196191

Closed

Description

@leehack

Steps to reproduce

Intermittent; no deterministic repro. On GitHub-hosted ubuntu-latest runners:

  1. Run flutter test --platform chrome <tests> in a package with web tests.
  2. All tests pass and package:test reports success (JSON reporter done with success: true).
  3. The flutter process does not exit and the CI job runs until its timeout.

Expected results

The process exits once the tests are done.

Actual results

The process hangs after success was reported. The exit code is already set by executable.dart before runner.close(), so the hang is in browser shutdown.

flutter_tools/lib/src/web/chrome.dart (lines 571-572 at 6655482) does:

await tab.connect();
await wipConnection.sendCommand('Browser.close');

There is no timeout and no fallback to killing the process. In webkit_inspection_protocol 1.2.1, _handleClose closes its streams but never completes the pending _completers (webkit_inspection_protocol.dart:251,264-299). If Chrome exits before its Browser.close reply arrives, the future never completes and Browser.close never returns.

Suggested fix, either or both:

  • Bound the Browser.close wait with a timeout and fall back to killing the Chrome process.
  • Complete pending completers with an error when the connection closes in webkit_inspection_protocol.

Seen in leehack/llamadart#1702.

Code sample

Not applicable; the hang is in tool shutdown after tests pass.

Logs

Not applicable; the log ends after the reporter's final done event with success: true and nothing further is printed.

Flutter Doctor output

Reproduced in CI on Flutter 3.47.1 (commit 6655482). The full flutter doctor -v is not attached because the hang was observed on CI runners.

Flutter 3.47.1 • channel [user-branch] • revision 6655482ec0 (3 months ago) • 2026-08-19 10:07:23 -0700
Engine • hash 11d79658c444477b06513d32b52c8c4ccb7276b0 (revision 5d53178869) • 2026-08-18

Activity

  1. added
    a: tests
    c: crash
    tool
    platform-web
    has reproducible steps
    team-tool
    found in release: 3.47
    on Nov 9, 2026
  2. mbcorona commented on Nov 9, 2026

    @mbcorona
    Member

    Thanks for the analysis @leehack.
    Routing to the tool team to review the PR.

  3. leehack commented on Nov 9, 2026

    @leehack
    ContributorAuthor

    Opened the package-side fix as well: google/webkit_inspection_protocol.dart#143. It fails pending sendCommand futures with a StateError when the connection closes, so Browser.close can no longer wait forever on a reply that will never arrive.

    It complements #196211 rather than replacing it: the timeout in Chromium.close still covers the case where Chrome stays alive but never answers, and it does not depend on a new package release being rolled in.

  4. added
    P2
    triaged-tool
    on Nov 10, 2026
  5. added a commit that references this issue on Nov 16, 2026
    29c22be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2a: testsc: crashfound in release: 3.47has reproducible stepsplatform-webteam-tooltooltriaged-tool

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions