iflytek/astron-agent · error

生成的 无效

Error message

生成的${set.type}无效

What it means

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.

Solutions

  1. Record for a minimum sensible duration (e.g. >500ms) before calling stop().
  2. 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).
  3. Verify the encoder for set.type is loaded and compatible with the environment.
  4. Check that onProcess buffers are actually accumulating (recSize > 0) before stop.
  5. Test on a foreground tab; background throttling can starve the audio capture loop.

Example fix

// before
rec.stop(function(blob) { upload(blob); });

// after: validate before consuming
rec.stop(function(blob, duration) {
  if (!blob || blob.size < Math.max(100, duration / 2)) {
    showToast('Recording too short or invalid, please try again');
    return;
  }
  upload(blob);
});
Defensive patterns

Strategy: validation

Validate before calling

rec.stop(function(blob, duration) {
  if (!blob || blob.size < Math.max(100, duration / 2)) {
    showToast('Recording is too short or invalid');
    return;
  }
  upload(blob);
});

Type guard

function isValidBlob(blob, duration) {
  return blob instanceof Blob && blob.size >= Math.max(100, duration / 2);
}

Try / catch

rec.stop(function(blob, duration) {
  if (!isValidBlob(blob, duration)) return retryRecording();
  upload(blob);
});

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/456e4f862be76c1e. Report an issue: GitHub.

Appendix: source

Thrown at console/frontend/src/utils/record/recorder-core.js:1363

      var ok = function (blob, duration, originBUffers, originSampleRate) {
        This.CLog(
          '结束录音 编码花' +
            (Date.now() - t1) +
            'ms 音频时长' +
            duration +
            'ms 文件大小' +
            blob.size +
            'b'
        );
        if (set.takeoffEncodeChunk) {
          //接管了输出,此时blob长度为0
          This.CLog(
            '启用takeoffEncodeChunk后stop返回的blob长度为0不提供音频数据',
            3
          );
        } else if (blob.size < Math.max(100, duration / 2)) {
          //1秒小于0.5k?
          err('生成的' + set.type + '无效');
          return;
        }
        True &&
          True(blob, duration, originBUffers || [], originSampleRate || 44100);
        end();
      };
      if (!This.isMock) {
        var isCtxWait = This.state == 3;
        if (!This.state || isCtxWait) {
          err(
            '未开始录音' +
              (isCtxWait ? ',开始录音前无用户交互导致AudioContext未运行' : '')
          );
          return;
        }
        This._stop(true);
      }
      var size = This.recSize;

View on GitHub (pinned to 5e758547a8)