Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDS] Subscribing to 'Service' stream throws 'Stream already subscribed' with two clients #45569

Closed
annagrin opened this issue Apr 2, 2021 · 3 comments
Assignees
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. pkg-dds For issues related to the Dart Development Service

Comments

@annagrin
Copy link
Contributor

annagrin commented Apr 2, 2021

I have a test in flutter_tools that connects two clients to the vmService on web that runs with DDS enabled. The first client can subscribe to 'Service' stream successfully. but the second cannot - subscribing to 'Service' causes 'Stream already subscribed' to be thrown.

See the following PR for example:
flutter/flutter#79479

@annagrin annagrin added the pkg-dds For issues related to the Dart Development Service label Apr 2, 2021
@bkonyi bkonyi self-assigned this Apr 2, 2021
@bkonyi
Copy link
Contributor

bkonyi commented Apr 2, 2021

It seems like this is caused by a data race that this test just happened to hit. In particular, this code:

await Future.wait(<Future<void>>[
  validateFlutterVersion(client1),
  validateFlutterVersion(client2),
]);

has two separate clients subscribing to the Service stream in validateFlutterVersion. These clients issue their streamListen requests simultaneously, and StreamManager processes them both at roughly the same time, allowing for both requests to bypass the checks we do to avoid having DDS try to subscribe to an existing stream.

We need some form of locking mechanism to ensure streamListen requests are processed atomically or refactor subscribed streams checks in such a way that streams are marked as subscribed by DDS before issuing the streamListen to the VM service.

@mraleph mraleph added the area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. label Apr 5, 2021
@annagrin
Copy link
Contributor Author

annagrin commented Jul 22, 2021

@bkonyi looks like this is still failing after re-enabling the flutter test:

07:41 +19 -1: test/web.shard/vm_service_web_test.dart: Clients of flutter run on web with DDS enabled can validate flutter version in parallel [E]                                                     
  streamListen: (-32000) Null check operator used on a null value
  package:vm_service/src/vm_service.dart 1626:45  new _OutstandingRequest
  package:vm_service/src/vm_service.dart 2109:21  VmService._call
  package:vm_service/src/vm_service.dart 2056:7   VmService.streamListen
  test/web.shard/vm_service_web_test.dart 129:16  validateFlutterVersion
  test/web.shard/vm_service_web_test.dart 62:9    main.<fn>.<fn>

DDS version: dds: 2.0.2
DWDS version: dwds: 11.1.2
VMService version: 7.1.1

PR: flutter/flutter#86832
Failing tests:

@annagrin annagrin reopened this Jul 22, 2021
@bkonyi
Copy link
Contributor

bkonyi commented Jul 22, 2021

@annagrin that isn't the same error. Can you please file another issue and assign it to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. pkg-dds For issues related to the Dart Development Service
Projects
None yet
Development

No branches or pull requests

3 participants