iflytek/astron-agent · error · Error

msg (dynamic; logged as '无法录音:'+msg and shown via…

Error message

msg (dynamic; logged as '无法录音:'+msg and shown via message.info)

What it means

In the recorder wrapper's open() promise flow, when opening the microphone fails the code shows message.info(msg), logs '无法录音:'+msg, rejects the promise, and then throws new Error(msg). The message text is dynamic — it comes from the underlying recorder-core failure (permission denied, no device, environment check, etc.).

Solutions

  1. Read the rejected/caught msg and route it: if isUserNotAllow, instruct the user to re-enable microphone permission in browser settings
  2. Serve the app over HTTPS (or localhost) so getUserMedia is available
  3. Check navigator.mediaDevices and Recorder.Support() before attempting to open
  4. Catch the error from the promise and stop the recording UI gracefully instead of letting the throw propagate

Example fix

// before
try { await media.open(); } catch (e) { throw e; }
// after
try {
  await media.open();
} catch (msg) {
  if (/UserNotAllow|NotAllowedError/.test(String(msg))) {
    message.warning('请在浏览器设置中允许麦克风权限');
  } else {
    message.error('无法录音: ' + msg);
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!navigator.mediaDevices || !Recorder.Support()) {
  message.error('当前环境不支持录音,请使用 HTTPS 的现代浏览器');
  return;
}

Type guard

function canRecord() {
  return !!(navigator.mediaDevices && typeof navigator.mediaDevices.getUserMedia === 'function');
}

Try / catch

try {
  await media.open();
} catch (msg) {
  message.error((String(msg).includes('UserNotAllow') ? '请允许麦克风权限' : '无法录音: ') + msg);
}

Prevention

When it happens

Trigger: Calling the wrapper's open/start when getUserMedia fails: user denied permission, no microphone available, page not in a secure context (non-HTTPS), recorder already open/closed, or an unsupported browser environment detected by Recorder.envCheck.

Common situations: Users blocking mic permission in Chrome; running the console on http:// during development so getUserMedia is undefined; kiosk/VM machines without an audio input device; iOS Safari restrictions.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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

Appendix: source

Thrown at console/frontend/src/utils/record/media.js:270

        _this.rec.open(
          () => {
            //打开麦克风授权获得相关资源
            clearTimeout(t);
            _this.rec.start(); //开始录音

            _this.RealTimeSendTryReset(); //重置环境,开始录音时必须调用一次
            resolve('success');
          },
          function (msg, isUserNotAllow) {
            clearTimeout(t);
            message.info(msg);
            console.error(
              (isUserNotAllow ? 'UserNotAllow,' : '') + '无法录音:' + msg,
              1
            );
            reject(msg);
            throw new Error(msg);
          }
        );
      });
    },

    sendData: function (audioData) {
      // console.log("audioData=>", audioData)
      this.ws.send(audioData);
      this.status = 1;
    },
  };
}
export default Media;

View on GitHub (pinned to 5e758547a8)