{"record":{"id":"49202f41d7eb9631","repo":"microsoft/typescript-go","slug":"socket-connections-are-not-yet-supported-in-the-sy","errorCode":null,"errorMessage":"Socket connections are not yet supported in the sync client","messagePattern":"Socket connections are not yet supported in the sync client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"_packages/native-preview/src/api/sync/client.ts","lineNumber":27,"sourceCode":"import { SyncRpcChannel } from \"../syncChannel.ts\";\r\nimport {\r\n    combineTimingInfo,\r\n    disabledTimingInfo,\r\n    type ServerTimingInfo,\r\n    TimingCollector,\r\n    type TimingInfo,\r\n} from \"../timing.ts\";\r\n\r\nexport type { ClientOptions, ClientSocketOptions, ClientSpawnOptions };\r\n\r\nexport class Client {\r\n    private channel: SyncRpcChannel;\r\n    private encoder = new TextEncoder();\r\n    private timing: TimingCollector | undefined;\r\n\r\n    constructor(options: ClientOptions) {\r\n        if (!isSpawnOptions(options)) {\r\n            throw new Error(\"Socket connections are not yet supported in the sync client\");\r\n        }\r\n\r\n        const cwd = options.cwd ?? process.cwd();\r\n        const args = [\r\n            \"--api\",\r\n            \"--cwd\",\r\n            cwd,\r\n        ];\r\n\r\n        // Enable virtual FS callbacks for each provided FS function\r\n        const enabledCallbacks: (typeof fsCallbackNames[number])[] = [];\r\n        if (options.fs) {\r\n            for (const name of fsCallbackNames) {\r\n                if (options.fs[name]) {\r\n                    enabledCallbacks.push(name);\r\n                }\r\n            }\r\n        }\r","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/_packages/native-preview/src/api/sync/client.ts#L9-L45","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Drop the 'pipe' property so the sync client spawns its own child: new Client({ cwd })","Or use the async API client (api/async/client.ts), which supports ClientSocketOptions","Type the options explicitly as ClientSpawnOptions so TypeScript rejects 'pipe' at compile time"],"exampleFix":"// before\nimport { Client } from \"@typescript/native-preview/api/sync\";\nconst c = new Client({ pipe: \"/tmp/tsgo.sock\" }); // throws\n\n// after\nimport { Client } from \"@typescript/native-preview/api/sync\";\nconst c = new Client({ cwd: process.cwd() });","handlingStrategy":"validation","validationCode":"const isSyncCompatible = (o: ClientOptions) => !(\"pipe\" in o);","typeGuard":"function isSpawnOptions(o: ClientOptions): o is ClientSpawnOptions {\n  return !(\"pipe\" in o);\n}","tryCatchPattern":"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; }","preventionTips":["Type sync-client options as ClientSpawnOptions so 'pipe' is a compile error","Import the async client when you need socket connections","Reuse the exported isSpawnOptions helper to branch on options shape"],"tags":["typescript","client","sync","unsupported-feature"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}