Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

fix(rome_cli): ensures the service only connects to compatible versions #3642

Merged
merged 3 commits into from
Nov 10, 2022

Conversation

leops
Copy link
Contributor

@leops leops commented Nov 10, 2022

Summary

Fixes #3637

This PR changes the path of the named pipe / domain socket used to communicate between the language client and server to include the version string of rome_service. This ensures a given instance of the Rome CLI binary always spawns (and connects to) an instance of the Rome daemon it's compatible with.

Due to the nature of this check (using filesystem paths) the comparison between version IDs is a strict equality, however as the version string of rome_service is an internal value we could change it independently from the main Rome version number. We could also truncate the patch number from the version string, but for now I expect even patch release of Rome may include breaking changes to the protocol so I'm leaving the full version string.

Test Plan

I tested this locally by running two versions of the Rome server in parallel (the prebuilt binary from the npm package and a locally built version of this branch) and ensuring each version of the CLI and editor extension were connection to the right version.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit f3f5713
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/636cfdfeafa43300087b912a

@leops leops added A-CLI Area: CLI A-LSP Area: language server protocol labels Nov 10, 2022
@MichaReiser
Copy link
Contributor

The rage command to this point discovered any running rome server. It allows to pull the logs from the LSP the VS Code extension is connected even if they don't have the same version (and prints the server version). That will no longer work after this change.

Should we extend the rage command to connect to any server handle?

@leops
Copy link
Contributor Author

leops commented Nov 10, 2022

The rage command to this point discovered any running rome server. It allows to pull the logs from the LSP the VS Code extension is connected even if they don't have the same version (and prints the server version). That will no longer work after this change.

Should we extend the rage command to connect to any server handle?

This would need to detect all the active daemon instances somehow, either by maintaining an explicit list of past rome_service versions and trying to connect to each (not forward compatible) or by enumerating the active sockets (I'd need to look up a way to enumerate the active named pipes in Windows, it might require some unsafe direct calls to the Windows API)

@MichaReiser
Copy link
Contributor

The rage command to this point discovered any running rome server. It allows to pull the logs from the LSP the VS Code extension is connected even if they don't have the same version (and prints the server version). That will no longer work after this change.
Should we extend the rage command to connect to any server handle?

This would need to detect all the active daemon instances somehow, either by maintaining an explicit list of past rome_service versions and trying to connect to each (not forward compatible) or by enumerating the active sockets (I'd need to look up a way to enumerate the active named pipes in Windows, it might require some unsafe direct calls to the Windows API)

I think it would be sufficient for now to iterate over all files and match by name, print the total numbers of running services and connect to the first.

@leops leops merged commit 90ec8a4 into main Nov 10, 2022
@leops leops deleted the feature/version-service-socket branch November 10, 2022 14:29
jeysal added a commit to jeysal/rometools that referenced this pull request Nov 10, 2022
* upstream/main:
  fix(npm/js-api): Import type from @rometools/backend-jsonrpc (rome#3647)
  doc(npm/js-api): Add experimental warning to README
  fix(npm/js-api): Lazy load backend implementations (rome#3652)
  feat(rome_lsp): stop the daemon after the last client disconnects (rome#3643)
  fix(npm/js_api): Ensure JS API build contains `dist` folder (rome#3648)
  fix(rome_cli): ensures the service only connects to compatible versions (rome#3642)
  feat(playground): add settings button and group IR (rome#3559)
  release: v10.0.1 (rome#3649)
  fix(rome_js_analyze): False positives for interactive elements in `useKeyWithClickEvents` (rome#3644)
  fix(rome_js_semantic): support for object and array bindings when exporting (rome#3620)
  doc(editors): Clarify Rome discovery (rome#3639)
  fix(rome_js_analyze): improve the detection of `ReactDOM.render` calls in `noRenderReturnValue` (rome#3626)
  chore(npm): add license (rome#3629)
  Add rustdocs index
  Add environment
  Change rust docs to use Netlify
  fix(rome_js_analyze): useValidAnchor considering all possible expressions (rome#3599)
  fix(rome_js_formatter): Trailing comma inside import rome#3600 (rome#3624)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-CLI Area: CLI A-LSP Area: language server protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📎 LSP: Spawn new LSP if the running LSP has a different version
3 participants