dart-lang / sdk

The Dart SDK, including the VM, dart2js, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
9.95k stars 1.53k forks source link

Passing `--protocol-traffic-log=` causes `dart language-server` to start the legacy server protocol #52501

Open 5hirish opened 1 year ago

5hirish commented 1 year ago

This tracker is for issues related to:

Passing --protocol-traffic-log seems to cause it to start the legacy server protocol. If I remove that argument, it starts the LSP protocol.

dart language-server --client-id my-editor.my-plugin --client-version 1.2 --protocol-traffic-log log.txt

image

Workaround: As a workaround, use --instrumentation-log-file instead of --protocol-traffic-log. They are aliases and do the same thing, but only the second one triggers this bug.

cc: @DanTup

DanTup commented 1 year ago

The problem seems to be here:

https://github.com/dart-lang/sdk/blob/fa5e8e2e0dcfb8646baa43b25629f5597a8ec1e6/pkg/dartdev/lib/src/commands/language_server.dart#L47

It's only passing --protocol=lsp is there is no argument that starts with --protocol, and --protocol-traffic-log starts with it.

My guess is that it's to handle --protocol=, but I think it should probably be == '--$protocol' || startsWith('--$protocol=') (and if there is any other valid syntax besides =).

srawlins commented 1 year ago

Thanks for digging, Danny!