{"record":{"id":"8879a23520766791","repo":"deepseek-ai/deepseek-harness","slug":"rpcid-mismatch-for-endpoint-sent-rpcid-got","errorCode":null,"errorMessage":"rpcId mismatch for ${endpoint}: sent ${rpcId}, got ${full.rpcId}","messagePattern":"rpcId mismatch for (.+?): sent (.+?), got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/client/connection/src/client/rpc.ts","lineNumber":49,"sourceCode":"        rpcId,\n        method: endpoint,\n        payload,\n      }\n      const response = await send(\n        new URL(`${channel}/${endpoint}`, resolveBase()),\n        {\n          method: 'POST',\n          headers: { 'content-type': 'application/json' },\n          body: JSON.stringify(message),\n          ...signal === undefined ? {} : { signal },\n        },\n      )\n      if (!response.ok) {\n        throw new Error(`transport failure for ${channel}/${endpoint}: HTTP ${response.status}`)\n      }\n      const full = serverResponseSchema.parse(await response.json())\n      if (full.rpcId !== rpcId) {\n        throw new Error(`rpcId mismatch for ${endpoint}: sent ${rpcId}, got ${full.rpcId}`)\n      }\n      return full.result\n    },\n  }\n}\n\nfunction resolveBase(): string {\n  const location = (globalThis as { location?: { origin?: string } }).location\n  return location?.origin !== undefined && location.origin !== 'null' ? location.origin : INTERNAL_BASE\n}\n\nfunction assertTarget(channel: string, endpoint: string): void {\n  const segments = endpoint.split('/')\n  if (!CHANNEL_PATTERN.test(channel)\n    || segments.some(segment =>\n      segment === '' || segment === '.' || segment === '..' || !ENDPOINT_SEGMENT_PATTERN.test(segment))) {\n    throw new Error(`connection: invalid RPC target ${JSON.stringify(`${channel}/${endpoint}`)}`)\n  }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/client/connection/src/client/rpc.ts#L31-L67","documentation":"Every unary call mints a random UUID rpcId, sends it inside the client-request envelope, and requires the server response envelope to echo it. A mismatch means the envelope answers a different request: typically a caching proxy or service worker replaying a stale response, an interleaving middlebox, or a server implementation that mints its own id instead of echoing the request's.","triggerScenarios":"rpc.call receives a schema-valid response whose rpcId differs from the sent one: HTTP or service-worker caches replaying an old POST response, a proxy mis-correlating concurrent requests, or a hand-written server that forgets to copy rpcId from request to response.","commonSituations":"A service worker or CDN configured to cache the RPC POST route; devtools offline-replay; a custom server generating fresh ids in the response envelope.","solutions":["If you control the server, echo the request envelope's rpcId verbatim instead of minting one","Disable HTTP and service-worker caching for the /api paths the RPC posts to","Retry the call once with a fresh id when the operation is idempotent; the stale cached envelope is usually evicted by then"],"exampleFix":"// before — server builds its own id\nconst response = { type: 'server-response', rpcId: RpcId(randomUuid()), result }\n\n// after — echo the request's id\nconst response = { type: 'server-response', rpcId: request.rpcId, result }","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async function callRetrying(rpc, channel, endpoint, payload, attempts = 2) {\n  for (let i = 0; ; i++) {\n    try {\n      return await rpc.call(channel, endpoint, payload)\n    } catch (error) {\n      if (i + 1 >= attempts || !String(error).includes('rpcId mismatch')) throw error\n    }\n  }\n}","preventionTips":["Never cache RPC POST responses; exclude /api from service-worker fetch handlers","Always echo the request's rpcId in server envelopes","Mint a fresh correlation id per attempt; never reuse ids across retries"],"tags":["rpc","correlation","protocol","caching"],"backgroundTag":"request-id-mismatch","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}