microsoft/typescript-go · error

Socket connections are not yet supported in the sync client

Error message

Socket connections are not yet supported in the sync client

What it means

The synchronous Client only supports spawning a local tsgo child process (ClientSpawnOptions: tsserverPath, cwd, fs, collectTiming). Its constructor detects socket options by the presence of a 'pipe' key and throws immediately, because synchronous RPC over an existing socket is not implemented. The async client (api/async) does support ClientSocketOptions.

Source

Thrown at _packages/native-preview/src/api/sync/client.ts:27

import { SyncRpcChannel } from "../syncChannel.ts";
import {
    combineTimingInfo,
    disabledTimingInfo,
    type ServerTimingInfo,
    TimingCollector,
    type TimingInfo,
} from "../timing.ts";

export type { ClientOptions, ClientSocketOptions, ClientSpawnOptions };

export class Client {
    private channel: SyncRpcChannel;
    private encoder = new TextEncoder();
    private timing: TimingCollector | undefined;

    constructor(options: ClientOptions) {
        if (!isSpawnOptions(options)) {
            throw new Error("Socket connections are not yet supported in the sync client");
        }

        const cwd = options.cwd ?? process.cwd();
        const args = [
            "--api",
            "--cwd",
            cwd,
        ];

        // Enable virtual FS callbacks for each provided FS function
        const enabledCallbacks: (typeof fsCallbackNames[number])[] = [];
        if (options.fs) {
            for (const name of fsCallbackNames) {
                if (options.fs[name]) {
                    enabledCallbacks.push(name);
                }
            }
        }

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Drop the 'pipe' property so the sync client spawns its own child: new Client({ cwd })
  2. Or use the async API client (api/async/client.ts), which supports ClientSocketOptions
  3. Type the options explicitly as ClientSpawnOptions so TypeScript rejects 'pipe' at compile time

Example fix

// before
import { Client } from "@typescript/native-preview/api/sync";
const c = new Client({ pipe: "/tmp/tsgo.sock" }); // throws

// after
import { Client } from "@typescript/native-preview/api/sync";
const c = new Client({ cwd: process.cwd() });
Defensive patterns

Strategy: validation

Validate before calling

const isSyncCompatible = (o: ClientOptions) => !("pipe" in o);

Type guard

function isSpawnOptions(o: ClientOptions): o is ClientSpawnOptions {
  return !("pipe" in o);
}

Try / catch

try { client = new Client(opts); } catch (e) { if ((e as Error).message.includes("Socket connections")) { client = new Client({ cwd: opts.cwd ?? process.cwd() }); } else throw e; }

Prevention

When it happens

Trigger: Constructing new Client({ pipe: '/tmp/tsgo.sock' }) (or any object with a 'pipe' property) from api/sync/client.ts — e.g. code ported from the async API or from LSP connection options (LSPConnectionOptions extends ClientSocketOptions).

Common situations: Sharing an options object between the async and sync clients; connecting to a long-lived tsgo server socket for performance, then accidentally importing the sync client; IDE integrations that already hold a pipe path.

Related errors


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/49202f41d7eb9631. Report an issue: GitHub.