{"record":{"id":"2c8375160626e9f6","repo":"iflytek/astron-agent","slug":"recorder-core","errorCode":null,"errorMessage":"未采集到录音","messagePattern":"未采集到录音","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"console/frontend/src/utils/record/recorder-core.js","lineNumber":1383,"sourceCode":"        }\n        True &&\n          True(blob, duration, originBUffers || [], originSampleRate || 44100);\n        end();\n      };\n      if (!This.isMock) {\n        var isCtxWait = This.state == 3;\n        if (!This.state || isCtxWait) {\n          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);","sourceCodeStart":1365,"sourceCodeEnd":1401,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/utils/record/recorder-core.js#L1365-L1401","documentation":"Recorder-Core's stop() checks This.recSize before encoding and errors when zero audio data was collected — the recorder ran (or was asked to stop) but never accumulated any PCM samples, so there is nothing to encode.","triggerScenarios":"rec.stop() is called when This.recSize is 0, i.e. no onProcess buffers arrived: start() was never effective, capture was stalled, or stop happened before the first audio chunk.","commonSituations":"Calling stop() immediately after start() (same tick); microphone captured silence due to a muted/disconnected device while frames never flushed; browser suspended audio processing without a user gesture; isMock environment without a processing env configured.","solutions":["Wait until onProcess has delivered data (or a small delay) after start() before calling stop().","Verify the microphone device is present, unmuted, and permission granted.","Ensure start() was called in a user-gesture handler so AudioContext is running.","Check rec.state and recSize before stop: only stop when recSize > 0.","If streaming chunks via takeoffEncodeChunk, remember data leaves via the worker path and stop-time size checks may legitimately see zero."],"exampleFix":"// before\nrec.start();\nrec.stop(); // error: no samples yet\n\n// after\nrec.start();\nsetTimeout(function() {\n  if (rec.recSize > 0) rec.stop();\n}, 1000);","handlingStrategy":"validation","validationCode":"function safeStop(rec, cb) {\n  if (!rec || rec.recSize === 0) { showToast('No audio captured'); return; }\n  rec.stop(cb);\n}","typeGuard":"function hasAudioData(rec) { return !!rec && rec.recSize > 0; }","tryCatchPattern":"rec.stop(function(blob) { ... }); // plus pre-check:\nif (!hasAudioData(rec)) { showToast('未采集到录音，请重新录制'); return; }","preventionTips":["Wait for onProcess data (or a delay) after start() before stopping.","Check mic permission and device availability before opening.","Start recording within a user gesture to keep AudioContext running.","Track recSize in UI and disable stop until data exists."],"tags":["audio","recording","microphone","javascript"],"backgroundTag":"empty-required-field","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"}