{"record":{"id":"841523c4a72002ae","repo":"iflytek/astron-agent","slug":"notsupportederror","errorCode":"NotSupportedError","errorMessage":"The adapter.js addTrack polyfill only supports a single  stream which is associated with the specified track.","messagePattern":"The adapter\\.js addTrack polyfill only supports a single  stream which is associated with the specified track\\.","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":19408,"sourceCode":"  }\n  ((e.RTCPeerConnection.prototype.removeStream = function (e) {\n    ((this._streams = this._streams || {}),\n      (this._reverseStreams = this._reverseStreams || {}),\n      n.apply(this, [this._streams[e.id] || e]),\n      delete this._reverseStreams[\n        this._streams[e.id] ? this._streams[e.id].id : e.id\n      ],\n      delete this._streams[e.id]);\n  }),\n    (e.RTCPeerConnection.prototype.addTrack = function (t, i) {\n      if ('closed' === this.signalingState)\n        throw new DOMException(\n          \"The RTCPeerConnection's signalingState is 'closed'.\",\n          'InvalidStateError'\n        );\n      const r = [].slice.call(arguments, 1);\n      if (1 !== r.length || !r[0].getTracks().find(e => e === t))\n        throw new DOMException(\n          'The adapter.js addTrack polyfill only supports a single  stream which is associated with the specified track.',\n          'NotSupportedError'\n        );\n      const n = this.getSenders().find(e => e.track === t);\n      if (n)\n        throw new DOMException('Track already exists.', 'InvalidAccessError');\n      ((this._streams = this._streams || {}),\n        (this._reverseStreams = this._reverseStreams || {}));\n      const o = this._streams[i.id];\n      if (o)\n        (o.addTrack(t),\n          Promise.resolve().then(() => {\n            this.dispatchEvent(new Event('negotiationneeded'));\n          }));\n      else {\n        const r = new e.MediaStream([t]);\n        ((this._streams[i.id] = r),\n          (this._reverseStreams[r.id] = i),","sourceCodeStart":19390,"sourceCodeEnd":19426,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/utils/avatar-sdk-web_3.1.2.1002/xrtc-player-BJTnVhG9.js#L19390-L19426","documentation":"The adapter.js addTrack polyfill predates multi-stream track association: it requires exactly one stream argument (r.length === 1) and that the given track actually belongs to that stream (r[0].getTracks().find(e => e === t)). If addTrack is called with zero arguments, multiple streams, or a stream that does not contain the track, it throws DOMException(..., 'NotSupportedError') because the polyfill cannot represent that case.","triggerScenarios":"Calling pc.addTrack(track) with no stream; pc.addTrack(track, streamA, streamB) with more than one stream; or pc.addTrack(track, streamB) where track came from a different MediaStream (common when tracks are re-wrapped, cloned, or re-muxed by the SDK).","commonSituations":"Modern code written against the spec's optional stream argument running on an old browser where adapter.js polyfills addTrack; passing a newly constructed MediaStream that only wraps the track by reference in a different browser context; SDK versions that hand the player re-wrapped streams.","solutions":["Always pass exactly one MediaStream that actually contains the track: pc.addTrack(track, streamContainingTrack).","Upgrade the browser or the avatar SDK/adapter.js bundle so the native addTrack (no polyfill) is used.","If the track is not in the stream, add it first (stream.addTrack(track)) before calling addTrack, or pass the stream the track actually came from.","Avoid cloning/re-wrapping tracks between streams before publishing."],"exampleFix":"// before\npc.addTrack(audioTrack); // no stream -> NotSupportedError in polyfill\n// after\nconst outStream = new MediaStream([audioTrack]);\npc.addTrack(audioTrack, outStream);","handlingStrategy":"validation","validationCode":"function canAddTrack(pc, track, stream) {\n  return stream && stream.getTracks().includes(track) && pc.signalingState !== 'closed';\n}","typeGuard":null,"tryCatchPattern":"try { pc.addTrack(track, stream); } catch (e) {\n  if (e.name === 'NotSupportedError' && /addTrack polyfill/.test(e.message)) {\n    stream.addTrack(track);\n    pc.addTrack(track, stream);\n  } else throw e;\n}","preventionTips":["Always supply exactly one stream argument containing the track","Do not pass cloned/re-wrapped streams whose track identity differs","Target browsers with native addTrack, or keep adapter.js current in the SDK bundle","Add a smoke test that publishes audio on the oldest supported browser"],"tags":["webrtc","adapter-js","polyfill","unsupported-operation","addtrack"],"backgroundTag":"unsupported-operation","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"}