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

Allow for dumping service protocol information to a file on startup #38418

Closed
bkonyi opened this issue Sep 16, 2019 · 7 comments
Closed

Allow for dumping service protocol information to a file on startup #38418

bkonyi opened this issue Sep 16, 2019 · 7 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@bkonyi
Copy link
Contributor

bkonyi commented Sep 16, 2019

Currently all tools wishing to connect to the service protocol need to scrape the URL and authentication codes from stdout. However, this isn't always possible or convenient (@DanTup mentioned some VSCode use cases that cannot rely on listening to stdout to get the service protocol information). The VM should provide a way to dump service protocol information to a file in a well known format that can be consumed by tooling (e.g., dart --observe --dump-service-info=service.json foo.dart).

Example format:

{
  "version": 1,
  "url": "http://127.0.0.1",
  "port": 8080,
  "authentication_code": "6iSIXM0fOBk=",
}
@bkonyi bkonyi added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Sep 16, 2019
@bkonyi bkonyi self-assigned this Sep 16, 2019
@bkonyi
Copy link
Contributor Author

bkonyi commented Sep 16, 2019

cc/ @zanderso would this functionality allow for us to enable authentication codes on Fuchsia?

@DanTup
Copy link
Collaborator

DanTup commented Sep 16, 2019

@DanTup mentioned some VSCode use cases that cannot rely on listening to stdout to get the service protocol information

To expand on this - our debug adapter currently owns the process (and streams) because we need to scrape the Observatory URI to connect the debugger. However we have no good way to let the user to then send input to stdin (so if they want to debug an interactive CLI app, they can't - Dart-Code/Dart-Code#99).

If we could get the info without needing to own stdout, then we can just spawn the process in a terminal and let them have full access to the streams themselves. Similar to the existing --pid-file option, for ex. dart --debugger-file=/tmp/somefile.json script.dart. Then we could just watch that file and read the debugger info from there (it could be deleted when the VM quits).

@zanderso
Copy link
Member

Regarding Fuchsia, this would probably not reduce the amount of plumbing needed to get the auth codes where they need to go since the port is already being read out of a file.

@DanTup
Copy link
Collaborator

DanTup commented Sep 18, 2019

@bkonyi this looks great! In the sample at the top you included a version number, though that doesn't seem to be in the written file - do you think we should add it?

It would also be nice to suppress the "Observatory listening" text (if easy) when this flag is supplied before we start using it (so there's no danger of anything using the flag also depending on the output).

When testing, I also saw this:

vm-service: isolate(401215214933043) 'main' has no debugger attached and is paused at start. Connect to Observatory at http://127.0.0.1:8181/HCf6LrZjZIo=/ to debug.

I don't know what triggers this - is it if no debugger attaches within a certain period? (If so, what is that period? it seems like it could be racy if the IDE doesn't connect fast enough - though I've never noticed it show up in the console before).

@DanTup
Copy link
Collaborator

DanTup commented Feb 24, 2020

@bkonyi I presume the URI here is still the Observatory web app, and for the VM service we should change the protocol to ws://, append the token and then /ws? If so, is there value in adding a vmServiceUri field that is the full websocket URI to simplify clients (and make it easier for the VM to change this in future if desired)?

@bkonyi
Copy link
Contributor Author

bkonyi commented Feb 28, 2020

@bkonyi I presume the URI here is still the Observatory web app, and for the VM service we should change the protocol to ws://, append the token and then /ws? If so, is there value in adding a vmServiceUri field that is the full websocket URI to simplify clients (and make it easier for the VM to change this in future if desired)?

That's correct. I don't think we output the websocket URI since it's rather easy to build from the Observatory URI. If this is something you think would be useful, would you mind filing a separate issue to track it?

@DanTup
Copy link
Collaborator

DanTup commented Feb 29, 2020

Sure, will do. It's not difficult to build, but it'd be nice to have done in one place (I also wasn't sure if the Observatory web app went away and the VM only hosted a WS, whether that would change things here - whereas a specific WS URI wouldn't need to change). Thanks!

Edit: #40839

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

3 participants