Skip to content

Bug: Webdev duplicates app connections for each refresh. #2604

Open
@schultek

Description

@schultek

The webdev daemon does not properly handle app reconnections. For each page refresh a new app connection is setup while the existing ones are still active. This causes duplicate app connections which quickly pile up after a few refreshes.

The code that causes this:

await for (final appConnection in dwds.connectedApps) {

dwds.connectedApps will emit a new appConnection whenever the browser refreshes, even if this app was already handled in webdev. The app will have the same id as an already active app in _appStates[appId], but this is never checked. Therefore all event handlers will be duplicated.


This can be observed simply by printing some logs on the client and refreshing the page:

Steps to reproduce:

  1. dart create bugtest -t web
  2. cd bugtest
  3. webdev daemon (Or launch a dart web debug session from vscode, which uses the daemon)
  4. Add print("Hello Web"); inside the main() in web/main.dart
  5. Go to chrome (should open automatically) and refresh the page multiple times.

Expected:

After each refresh ONE log event is printed to the terminal, e.g.
[{"event":"app.log","params":{"appId":"CxpfkG6Rz+5OTXWmy8kREA==","log":"Hello Web\n"}}]

Actual:

After each refresh DUPLICATE log events are printed in the number of past refreshes. E.g. after the 10th refresh, 10 duplicate log events are printed.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onpackage:webdevtriaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions