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

DevTools server is not robust when it has multiple devtools clients connected to different apps #55073

Open
kenzieschmoll opened this issue Feb 29, 2024 · 0 comments
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

@kenzieschmoll
Copy link
Contributor

DevTools server has a one-to-many relationship with DevTools app clients. Each client can be connected to a different VM service connection.

This will cause issues for cases where we are setting information on the server that is specific to a single VM service connection.

One example is the case where DTD is started by DevTools server (in progress here: https://dart-review.googlesource.com/c/sdk/+/354460).

Imagine this scenario:

  1. A user runs an app FOO from the command line.
  2. DevTools server is started.
  3. DevTools server starts the Dart Tooling Daemon (DTD).
  4. User opens the DevTools link printed to command line.
  5. DevTools app sets the workspace directories for DTD (see Add a DevTools server API to notify when a vm service connection changes flutter/devtools#7291).
  6. User copies the DevTools URL and pastes it into a new tab. There are now two DevTools app clients connected to the DevTools server.
  7. In the second instance of DevTools app, the user disconnects DevTools from app FOO, and connects DevTools to a different Dart or Flutter app (BAR).
  8. Issue: DevTools app (instance 2) sets the workspace directories for DTD, but now the workspace directories apply to both DevTools app client connections. Meaning the workspace directories will be incorrect for the DevTools instance connected to app FOO.

Proposal
Create contexts on the DevTools server for each VM service connection. When a DevTools client connects to a VM service, DevTools app can post an event to DevTools server. At this time, DevTools server can create a "context" for the new VM service connection, or use an existing one if one exists.

By "context" in this case, I mean DevTools server should keep VM-specific data separated by VM service connection. An example for the DTD scenario above could look like this:

  1. A user runs an app FOO from the command line.
  2. DevTools server is started.
  3. User opens the DevTools link printed to command line.
  4. DevTools app sends an event to the DevTools server notifying of the VM service connection in the client.
  5. DevTools server stores the VM service URI, spins up a DTD instance for this "context" and can set the workspace roots for DTD by connecting to the VM service to detect them.
  6. User copies the DevTools URL and pastes it into a new tab. There are now two DevTools app clients connected to the DevTools server.
  7. DevTools app sends an event to the DevTools server notifying of the VM service connection in the client (instance 2).
  8. Since DevTools server already has a "context" for this VM service connection, it does nothing and re-uses the existing client.
  9. In the second instance of DevTools app, the user disconnects DevTools from app FOO, and connects DevTools to a different Dart or Flutter app (BAR).
  10. DevTools app sends an event to the DevTools server notifying of the VM service connection in the client. DevTools server does not have a "context" for this VM service, so it repeats the steps it took for the first VM service client. It stores the VM service URI, spins up a DTD instance for this "context" and can set the workspace roots for DTD by connecting to the VM service to detect them.
@lrhn lrhn added area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. pkg-dds For issues related to the Dart Development Service labels Feb 29, 2024
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

2 participants