{"record":{"id":"326103a3417b3501","repo":"microsoft/typescript-go","slug":"name-mismatch-for-response-expected-method","errorCode":null,"errorMessage":"name mismatch for response: expected `${method}`, got `${this._msgName.toString(\"utf-8\")}`","messagePattern":"name mismatch for response: expected `(.+?)`, got `(.+?)`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"_packages/native-preview/src/api/syncChannel.ts","lineNumber":302,"sourceCode":"\r\n    private requestBytesSync(method: string, payload: Buffer | Uint8Array | string): Buffer {\r\n        const methodBuf = this.getMethodBuf(method);\r\n        if (this.collectTiming) {\r\n            this.lastBytesSent = typeof payload === \"string\"\r\n                ? Buffer.byteLength(payload, \"utf-8\")\r\n                : payload.length;\r\n            this.lastBytesReceived = 0;\r\n        }\r\n        this.writeTuple(MSG_REQUEST, methodBuf, payload);\r\n\r\n        for (;;) {\r\n            this.readTuple();\r\n\r\n            switch (this._msgType) {\r\n                case MSG_RESPONSE: {\r\n                    // Compare raw bytes instead of decoding to string.\r\n                    if (!methodBuf.equals(this._msgName)) {\r\n                        throw new Error(\r\n                            `name mismatch for response: expected \\`${method}\\`, got \\`${this._msgName.toString(\"utf-8\")}\\``,\r\n                        );\r\n                    }\r\n                    if (this.collectTiming) {\r\n                        this.lastBytesReceived = this._msgPayload.length;\r\n                    }\r\n                    return this._msgPayload;\r\n                }\r\n                case MSG_ERROR: {\r\n                    if (methodBuf.equals(this._msgName)) {\r\n                        throw new Error(this._msgPayload.toString(\"utf-8\"));\r\n                    }\r\n                    throw new Error(\r\n                        `name mismatch for response: expected \\`${method}\\`, got \\`${this._msgName.toString(\"utf-8\")}\\``,\r\n                    );\r\n                }\r\n                case MSG_CALL: {\r\n                    this.handleCall(this._msgName.toString(\"utf-8\"), this._msgPayload);\r","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/_packages/native-preview/src/api/syncChannel.ts#L284-L320","documentation":"In the request loop, a MSG_RESPONSE frame must echo the method name of the outstanding request. The channel is strictly synchronous (one request, one matched reply), so receiving a response named differently from the request means the message stream is out of alignment — responses are being matched to the wrong calls. The channel throws rather than returning mismatched payloads, because the payload would belong to a different method.","triggerScenarios":"Protocol desync: a previous request/response got corrupted or partially read (transport issue), the server emitted frames out of order, or client and server disagree on the framing protocol (version mismatch). Should never happen in normal operation.","commonSituations":"Client package and tsgo binary from different releases; corrupted pipe data on flaky transports; a bug in the channel or server framing. Essentially always a bug report candidate, not a caller error.","solutions":["Update @typescript/native-preview so client and bundled binary match","Recreate the Client — the channel state is untrustworthy after desync and cannot recover in place","Report upstream with both names from the message ('expected X, got Y') — it localizes the desync"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { resp = channel.request(method, payload); } catch (e) { if ((e as Error).message.includes(\"name mismatch for response\")) { /* channel desynced: recreate Client, do not reuse */ } else throw e; }","preventionTips":["Keep client and tsgo binary versions matched","Treat any name-mismatch error as fatal for the channel — recreate the client","Report expected/got names upstream"],"tags":["typescript","rpc","protocol","desync","internal"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}