Skip to content

Enable synchronous API connections to existing servers - #64175

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

Jake Bailey (jakebailey) wants to merge 3 commits 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 thread packages/typescript/src/api/syncChannel.ts Outdated
Comment thread packages/typescript/src/api/syncChannel.ts Outdated
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.
Nonblocking FIFO probes introduce polling delays into synchronous API
requests. Client I/O should wait for responses without that latency,
while server I/O remains cancellable during shutdown.

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 readiness marker can let the LSP server unlink FIFO paths before the client opens its final descriptors.

1 open finding
2 resolved since last review
Files not reviewed (1)
  • tsc/internal/lsp/lsproto/lsp_generated.go: Generated file

🧠 Review effort: Balanced

Comment thread packages/typescript/src/api/syncChannel.ts Outdated
The LSP server removes FIFO paths as soon as it accepts a connection.
Signaling readiness too early lets that cleanup race with the client's
final descriptor opens, causing intermittent connection failures.

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.

🔵 Needs a closer look

Cross-platform FIFO and named-pipe lifecycle behavior warrants final human validation.

0 open findings

1 resolved since last review
Files not reviewed (1)
  • tsc/internal/lsp/lsproto/lsp_generated.go: Generated file

🧠 Review effort: Balanced

This branch has not been deployed

No deployments
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