{"record":{"id":"456e4f862be76c1e","repo":"iflytek/astron-agent","slug":"set-type","errorCode":null,"errorMessage":"生成的${set.type}无效","messagePattern":"生成的\\$\\{set\\.type\\}无效","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"console/frontend/src/utils/record/recorder-core.js","lineNumber":1363,"sourceCode":"      var ok = function (blob, duration, originBUffers, originSampleRate) {\n        This.CLog(\n          '结束录音 编码花' +\n            (Date.now() - t1) +\n            'ms 音频时长' +\n            duration +\n            'ms 文件大小' +\n            blob.size +\n            'b'\n        );\n        if (set.takeoffEncodeChunk) {\n          //接管了输出，此时blob长度为0\n          This.CLog(\n            '启用takeoffEncodeChunk后stop返回的blob长度为0不提供音频数据',\n            3\n          );\n        } else if (blob.size < Math.max(100, duration / 2)) {\n          //1秒小于0.5k？\n          err('生成的' + set.type + '无效');\n          return;\n        }\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;","sourceCodeStart":1345,"sourceCodeEnd":1381,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/utils/record/recorder-core.js#L1345-L1381","documentation":"Recorder-Core's stop() validated the produced encoded blob and rejected it as too small: blob.size < Math.max(100, duration/2), meaning the encoded output is suspiciously empty or truncated for the recorded duration. The set.type names the encoder (e.g. wav/mp3) whose output is invalid.","triggerScenarios":"stop() finished encoding but the blob size fell below 100 bytes or below duration/2, despite takeoffEncodeChunk being disabled — e.g. encoding produced near-zero output even though recording ran for a while.","commonSituations":"Recording stopped almost immediately after start (duration ~0); buffers were captured but the encoder context (This[set.type]) produced an empty result; worker/takeoffEncodeChunk misconfiguration diverted the data elsewhere; heavy page throttling in background tabs stalled sample capture.","solutions":["Record for a minimum sensible duration (e.g. >500ms) before calling stop().","If you use takeoffEncodeChunk for streaming, handle the blob yourself and don't rely on stop()'s return value (the log right above this error indicates exactly that pattern).","Verify the encoder for set.type is loaded and compatible with the environment.","Check that onProcess buffers are actually accumulating (recSize > 0) before stop.","Test on a foreground tab; background throttling can starve the audio capture loop."],"exampleFix":"// before\nrec.stop(function(blob) { upload(blob); });\n\n// after: validate before consuming\nrec.stop(function(blob, duration) {\n  if (!blob || blob.size < Math.max(100, duration / 2)) {\n    showToast('Recording too short or invalid, please try again');\n    return;\n  }\n  upload(blob);\n});","handlingStrategy":"validation","validationCode":"rec.stop(function(blob, duration) {\n  if (!blob || blob.size < Math.max(100, duration / 2)) {\n    showToast('Recording is too short or invalid');\n    return;\n  }\n  upload(blob);\n});","typeGuard":"function isValidBlob(blob, duration) {\n  return blob instanceof Blob && blob.size >= Math.max(100, duration / 2);\n}","tryCatchPattern":"rec.stop(function(blob, duration) {\n  if (!isValidBlob(blob, duration)) return retryRecording();\n  upload(blob);\n});","preventionTips":["Enforce a minimum recording duration before allowing stop.","Don't mix takeoffEncodeChunk streaming with stop()-returned blob expectations.","Verify encoder output size in a smoke test per target browser.","Keep the tab foreground during recording to avoid throttling."],"tags":["audio","recording","encoding","javascript"],"backgroundTag":"unexpected-response-shape","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"}