Skip to content

Enable synchronous API connections to existing servers - #64175

Draft
Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:redo-api-fifos
Draft

Enable synchronous API connections to existing servers#64175
Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:redo-api-fifos

Conversation

@jakebailey

Copy link
Copy Markdown
Member

This is some work I had back on the old repo that I've now brought back up to date.

Right now, you can only open an async connection with an existing server process. But, we can provide the sync API if we use FIFOs/named pipes; such a thing is not possible from Node as it irritatingly does not have mkfifo or anything, but we can just do that on the Go side and then the API can talk to that instead, which to that process just looks like stdio.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The Unix client retains nonblocking FIFO descriptors, adding polling latency to synchronous requests.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds synchronous API connections to existing standalone and LSP servers using FIFOs on Unix and named pipes on Windows.

Changes:

  • Adds selectable stdio, socket, and synchronous transports.
  • Extends clients and VS Code integration with synchronous sessions.
  • Adds cross-platform connection and cleanup tests.
File summaries
File Description
tsc/internal/lsp/server.go Creates async or synchronous API sessions.
tsc/internal/lsp/lsproto/lsp_generated.go Adds the synchronous request option.
tsc/internal/lsp/lsproto/_generate/generate.mts Generates the new protocol field.
tsc/internal/ipc/transport.go Adds cancellable transport acceptance.
tsc/internal/ipc/transport_windows.go Uses named pipes for sync transport.
tsc/internal/ipc/transport_unix.go Implements FIFO transport and cleanup.
tsc/internal/api/server.go Generalizes server transport selection.
tsc/cmd/tsc/api.go Adds the --transport option.
packages/vscode-typescript/src/session.ts Forwards synchronous session requests.
packages/vscode-typescript/src/extension.ts Exposes synchronous connection selection.
packages/vscode-typescript/src/client.ts Sends the synchronous protocol field.
packages/typescript/test/sync/connection.test.ts Tests standalone and LSP sync connections.
packages/typescript/src/api/syncChannel.ts Connects sync channels to existing servers.
packages/typescript/src/api/sync/client.ts Enables socket-style sync clients.
packages/typescript/src/api/sync/api.ts Updates generated sync API documentation.
packages/typescript/src/api/options.ts Documents transport-specific pipe behavior.
packages/typescript/src/api/async/api.ts Updates connection documentation.
Review details

Files not reviewed (1)

  • tsc/internal/lsp/lsproto/lsp_generated.go: Generated file
  • Files reviewed: 16/17 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +254 to +255
const readFd = probeReadFd;
const writeFd = probeWriteFd;
Comment on lines 94 to +95
* The protocol is unversioned; both sides (this JS channel and the Go
* child process) must be built from the same tree.
* server must be built from the same tree.
Allow the synchronous JavaScript API to attach to standalone and LSP-hosted API sessions without spawning another compiler process. Use FIFO pairs on Unix and named pipes on Windows, with cancellable setup and cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants