{"record":{"id":"b4a8ecd61661a87e","repo":"iflytek/astron-agent","slug":"typeerror","errorCode":"TypeError","errorMessage":"Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","messagePattern":"Argument 1 of RTCPeerConnection\\.removeTrack does not implement interface RTCRtpSender\\.","errorType":"exception","errorClass":"DOMException","httpStatus":null,"severity":"error","filePath":"console/frontend/src/utils/avatar-sdk-web_3.1.2.1002/xrtc-player-BJTnVhG9.js","lineNumber":19485,"sourceCode":"  };\n  const a = Object.getOwnPropertyDescriptor(\n    e.RTCPeerConnection.prototype,\n    'localDescription'\n  );\n  (Object.defineProperty(e.RTCPeerConnection.prototype, 'localDescription', {\n    get() {\n      const e = a.get.apply(this);\n      return '' === e.type ? e : o(this, e);\n    },\n  }),\n    (e.RTCPeerConnection.prototype.removeTrack = function (e) {\n      if ('closed' === this.signalingState)\n        throw new DOMException(\n          \"The RTCPeerConnection's signalingState is 'closed'.\",\n          'InvalidStateError'\n        );\n      if (!e._pc)\n        throw new DOMException(\n          'Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.',\n          'TypeError'\n        );\n      if (e._pc !== this)\n        throw new DOMException(\n          'Sender was not created by this connection.',\n          'InvalidAccessError'\n        );\n      let t;\n      ((this._streams = this._streams || {}),\n        Object.keys(this._streams).forEach(i => {\n          this._streams[i].getTracks().find(t => e.track === t) &&\n            (t = this._streams[i]);\n        }),\n        t &&\n          (1 === t.getTracks().length\n            ? this.removeStream(this._reverseStreams[t.id])\n            : t.removeTrack(e.track),","sourceCodeStart":19467,"sourceCodeEnd":19503,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/utils/avatar-sdk-web_3.1.2.1002/xrtc-player-BJTnVhG9.js#L19467-L19503","documentation":"Thrown by the adapter.js removeTrack polyfill when the argument passed to RTCPeerConnection.removeTrack is not a real RTCRtpSender — the polyfill detects this via the internal _pc marker property that native senders (or polyfilled senders) carry. A plain object, an undefined value, or a sender produced by a different/connection-incompatible implementation lacks _pc and triggers this TypeError.","triggerScenarios":"Passing null/undefined to pc.removeTrack(), passing a mock or a deserialized sender object, or passing a sender obtained from a different peer connection or from a different adapter version than the one installed on this pc.","commonSituations":"Storing senders in state (e.g. React state or JSON) that loses the internal fields, refactoring that passes an event.track instead of event.sender, or mixing the bundled XRTC adapter with a natively created connection.","solutions":["Only pass senders obtained directly from pc.getSenders() or the ontrack event's event.sender of the same pc.","Validate before calling: if (sender && pc.getSenders().includes(sender)) pc.removeTrack(sender).","Fix code that passes event.track or a sender id instead of the RTCRtpSender object.","Do not serialize/clone senders across boundaries; keep live references."],"exampleFix":"// before\npc.removeTrack(evt.track); // wrong object\n\n// after\nconst sender = pc.getSenders().find(s => s.track === evt.track);\nif (sender) pc.removeTrack(sender);","handlingStrategy":"type-guard","validationCode":"function isValidSender(pc, sender) {\n  return !!sender && typeof sender.track !== 'undefined' && pc.getSenders().includes(sender);\n}","typeGuard":"function isSender(pc, s) {\n  return !!s && '_pc' in s && pc.getSenders().includes(s);\n}","tryCatchPattern":"try {\n  pc.removeTrack(sender);\n} catch (e) {\n  if (e instanceof TypeError) {\n    // argument was not an RTCRtpSender; resolve correct sender via getSenders()\n  } else throw e;\n}","preventionTips":["Pass only senders from pc.getSenders() or ontrack's event.sender.","Never pass event.track where a sender is required.","Do not serialize/clone sender objects across state boundaries.","Look up the sender at call time instead of caching loose references."],"tags":["webrtc","polyfill","type-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}