{"record":{"id":"ad86b14135b11c0c","repo":"iflytek/astron-agent","slug":"checkmsg","errorCode":null,"errorMessage":"录音错误：${checkMsg}","messagePattern":"录音错误：\\$\\{checkMsg\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"console/frontend/src/utils/record/recorder-core.js","lineNumber":1401,"sourceCode":"        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(\n          (engineCtx.pcmSize / set[sampleRateTxt]) * 1000\n        ); //采用后的数据长度和buffers的长度可能微小的不一致，是采样率连续转换的精度问题\n\n        t1 = Date.now();\n        This[set.type + '_complete'](\n          engineCtx,\n          function (blob) {\n            ok(blob, duration);\n          },\n          err","sourceCodeStart":1383,"sourceCodeEnd":1419,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/utils/record/recorder-core.js#L1383-L1419","documentation":"Recorder-Core's stop() runs This.envCheck for mock recordings (isMock=true) and prepends any returned environment-compat message to '录音错误：'. When a mock environment (mockEnvInfo, e.g. envName:'mock', canProcess:false) reports it cannot process audio, stop aborts with this composed error.","triggerScenarios":"rec.stop() on a recorder constructed with isMock:true whose mockEnvInfo either isn't provided (defaults to {envName:'mock', canProcess:false}) or whose envCheck returns a non-empty incompatibility message.","commonSituations":"Testing/recording in non-browser environments (SSR, WeChat/native webview without proper env registration, jsdom in unit tests); mock recorder created without passing mockEnvInfo; canProcess left false because the platform shim (e.g. native recorder bridge) wasn't installed.","solutions":["Don't use isMock in a real browser — use the normal recorder; mock is only for custom/native environments.","Provide mockEnvInfo with canProcess:true and a working envCheck implementation when using mocks.","Register the platform environment (envCheck shim) before constructing the mock recorder.","Route the error to a fallback: skip recording or surface a clear 'environment not supported' message to users.","In unit tests, assert envCheck passes before exercising stop()."],"exampleFix":"// before\nvar rec = Recorder({ type: 'wav', isMock: true }); // no mockEnvInfo\nrec.stop(cb); // '录音错误：mock canProcess=false'\n\n// after\nvar rec = Recorder({\n  type: 'wav',\n  isMock: true,\n  mockEnvInfo: { envName: 'myNative', canProcess: true, envCheck: function() { return myBridgeReady ? '' : 'bridge not ready'; } }\n});","handlingStrategy":"fallback","validationCode":"if (rec.isMock && rec.mockEnvInfo && typeof rec.mockEnvInfo.envCheck === 'function') {\n  const msg = rec.mockEnvInfo.envCheck(rec.mockEnvInfo);\n  if (msg) { showToast('Environment unsupported: ' + msg); return; }\n}","typeGuard":"function mockEnvUsable(rec) { return !rec.isMock || (!!rec.mockEnvInfo && rec.mockEnvInfo.canProcess === true); }","tryCatchPattern":"try { rec.stop(cb); } catch (e) {\n  if (String(e).includes('录音错误')) fallbackToTextCapture();\n}","preventionTips":["Only use isMock in genuinely custom/native environments.","Always provide mockEnvInfo with canProcess:true and a real envCheck when mocking.","Install the platform env shim before creating the recorder.","Provide a non-audio fallback path for unsupported environments."],"tags":["audio","recording","mock","environment","javascript"],"backgroundTag":"unsupported-platform","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"}