{"record":{"id":"4b3b950e80ad882b","repo":"iflytek/astron-agent","slug":"set-type-recorder-core","errorCode":null,"errorMessage":"未加载${set.type}编码器","messagePattern":"未加载(.+?)编码器","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"console/frontend/src/utils/record/recorder-core.js","lineNumber":1391,"sourceCode":"          err(\n            '未开始录音' +\n              (isCtxWait ? '，开始录音前无用户交互导致AudioContext未运行' : '')\n          );\n          return;\n        }\n        This._stop(true);\n      }\n      var size = This.recSize;\n      if (!size) {\n        err('未采集到录音');\n        return;\n      }\n      if (!This.buffers[0]) {\n        err('音频buffers被释放');\n        return;\n      }\n      if (!This[set.type]) {\n        err('未加载' + set.type + '编码器');\n        return;\n      }\n\n      //环境配置检查，此处仅针对mock调用，因为open已经检查过了\n      if (This.isMock) {\n        var checkMsg = This.envCheck(\n          This.mockEnvInfo || { envName: 'mock', canProcess: false }\n        ); //没有提供环境信息的mock时没有onProcess回调\n        if (checkMsg) {\n          err('录音错误：' + checkMsg);\n          return;\n        }\n      }\n\n      //此类型有边录边转码(Worker)支持\n      var engineCtx = This.engineCtx;\n      if (This[set.type + '_complete'] && engineCtx) {\n        var duration = Math.round(","sourceCodeStart":1373,"sourceCodeEnd":1409,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/utils/record/recorder-core.js#L1373-L1409","documentation":"Recorder-Core's stop() verifies that the encoder for set.type (e.g. 'wav', 'mp3') is registered on the recorder instance; This[set.type] is falsy when the corresponding encoder plugin/extension was never loaded, so stop cannot transcode the PCM buffers.","triggerScenarios":"stop() called with set.type set to a format whose encoder file (e.g. recorder-mp3.js defining Recorder.MP3 encoder context) was never included, or set.type string doesn't match the registered encoder key.","commonSituations":"Set type:'mp3' but only recorder-core.js loaded without recorder-mp3.min.js; typo in set.type ('MP3' vs 'mp3' case mismatch); bundler tree-shook the encoder side-effect registration; dynamically chosen type not reflected in the scripts loaded on the page.","solutions":["Include the encoder script for the configured type (e.g. <script src=\"recorder-mp3.min.js\">) after recorder-core.js.","Ensure set.type exactly matches the registered encoder name (case-sensitive).","Verify with your bundler that the encoder module's side-effect (window.Recorder['mp3']=...) isn't stripped; import it for side effects.","Log Object.keys available encoders and check set.type before calling stop.","Fall back to a format you know is loaded (e.g. wav) if the desired encoder is unavailable."],"exampleFix":"// before\nRecorder({ type: 'mp3', ... }) // recorder-mp3.js never loaded\n\n// after\n<script src=\"recorder-core.js\"></script>\n<script src=\"recorder-mp3.min.js\"></script>\n...\nif (!Recorder['mp3'] /* or window-level check */) {\n  showToast('MP3 encoder not loaded');\n} else {\n  rec.stop(uploadBlob);\n}","handlingStrategy":"validation","validationCode":"const types = ['wav', 'mp3'];\nif (!Recorder[set.type] && !window.Recorder?.[set.type]) {\n  throw new Error(`Encoder for type '${set.type}' not loaded — include its script`);\n}","typeGuard":"function encoderLoaded(type) { return typeof window.Recorder === 'object' && !!Recorder[type]; }","tryCatchPattern":"if (!encoderLoaded(rec.set.type)) {\n  showToast('Encoder missing: ' + rec.set.type);\n  return;\n}\nrec.stop(uploadBlob);","preventionTips":["Ship the encoder script matching every configured set.type.","Match set.type exactly (case) to the registered encoder key.","Import encoder modules for side effects in bundled apps.","Add a startup check that all needed encoders are registered."],"tags":["audio","recording","encoder","javascript","missing-dependency"],"backgroundTag":"missing-dependency","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"}