{"record":{"id":"8a067cad01a5f59a","repo":"microsoft/playwright","slug":"cannot-find-command-to-respond-id","errorCode":null,"errorMessage":"Cannot find command to respond: ${id}","messagePattern":"Cannot find command to respond: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/connection.ts","lineNumber":244,"sourceCode":"  private _validatorFromWireContext(): ValidatorContext {\n    return {\n      tChannelImpl: this._tChannelImplFromWire.bind(this),\n      binary: this._rawBuffers ? 'buffer' : 'fromBase64',\n      isUnderTest,\n    };\n  }\n\n  dispatch(message: object) {\n    if (this._closedError)\n      return;\n\n    const { id, guid, method, params, result, error, errorDetails, log } = message as any;\n    if (id) {\n      if (debugLogger.isEnabled('channel'))\n        debugLogger.log('channel', '<RECV ' + JSON.stringify(message));\n      const callback = this._callbacks.get(id);\n      if (!callback)\n        throw new Error(`Cannot find command to respond: ${id}`);\n      this._callbacks.delete(id);\n      if (error && !result) {\n        const parsedError = parseError(error);\n        if (callback.signal?.aborted && parsedError instanceof AbortError)\n          parsedError.cause = callback.signal.reason;\n        parsedError.log = log || [];\n        rewriteErrorMessage(parsedError, parsedError.message + formatCallLog(log));\n        const detailsValidator = maybeFindValidator(callback.type, callback.method, 'ErrorDetails');\n        if (detailsValidator)\n          parsedError.details = detailsValidator(errorDetails ?? {}, '', this._validatorFromWireContext());\n        callback.reject(parsedError);\n      } else {\n        const validator = findValidator(callback.type, callback.method, 'Result');\n        callback.resolve(validator(result, '', this._validatorFromWireContext()));\n      }\n      return;\n    }\n","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/client/connection.ts#L226-L262","documentation":"Thrown in dispatch() when a response message arrives with an id that has no entry in _callbacks (after the _closedError guard). The callback was either already invoked and deleted, or the callbacks map was cleared. This is an internal protocol-consistency violation: the server produced a response the client was no longer expecting.","triggerScenarios":"Server sends a duplicate response for an id; a response arrives after the callback was already resolved/rejected; race between an in-flight request and connection teardown where the map was cleared; a custom transport replays or reorders messages. Practically unreachable in normal use — it indicates transport/server bugs or message duplication.","commonSituations":"Misbehaving proxy or custom transport that duplicates frames; running an experimental/patched server; extremely rare races under heavy message volume; using an unofficial server implementation.","solutions":["Confirm you are using the same Playwright version on client and server.","If you are behind a proxy/custom WebSocket transport, check it for message duplication or reordering.","Capture a 'channel' debug log (DEBUG=pw:channel) to confirm duplicate/out-of-order responses.","Report with the reproduction if it persists against an unmodified server — this should not happen in normal operation."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// This is an internal protocol error — wrap the broad operation, log, and reconnect.\ntry {\n  await page.someMethod();\n} catch (e) {\n  if (/Cannot find command to respond/.test(String(e?.message))) {\n    // Transport/server produced a duplicate or out-of-order response.\n    // Only sane recovery is a fresh connection.\n    await reconnect();\n  } else throw e;\n}","preventionTips":["Use the bundled transport; avoid custom WebSocket proxies that duplicate frames.","Keep client and server on identical Playwright versions.","Enable DEBUG=pw:channel in CI to capture protocol anomalies early."],"tags":["protocol","internal","transport","race-condition"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}