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
Same dynamic open-failure error as in media.js, thrown from record.js's open() promise handler. When the microphone cannot be opened, the wrapper shows message.info(msg), logs '无法录音:'+msg, rejects the promise with msg, and throws new Error(msg). msg is the underlying recorder-core reason string.
Solutions
- Inspect the caught msg: UserNotAllow → prompt user to reset site permissions; open被取消/中断 → fix open/close call ordering in your UI logic
- Ensure HTTPS or localhost origin
- Guard with Recorder.Support() / navigator.mediaDevices existence check before opening
- Handle the promise rejection so the thrown error does not surface as an uncaught exception
Example fix
// before
record.open(() => start()).catch((m) => { throw m; });
// after
record.open(
() => start(),
(msg, isUserNotAllow) => {
isUserNotAllow
? message.warning('请允许麦克风权限后重试')
: message.error('无法录音: ' + msg);
}
).catch(() => {}); Defensive patterns
Strategy: try-catch
Validate before calling
if (!navigator.mediaDevices?.getUserMedia) {
message.error('录音不可用:需要 HTTPS 环境');
return;
} Type guard
function micAvailable() { return !!navigator.mediaDevices?.getUserMedia; } Try / catch
record.open(
() => start(),
(msg, isUserNotAllow) => isUserNotAllow
? message.warning('请允许麦克风权限')
: message.error('无法录音: ' + msg)
); Prevention
- Handle the False callback instead of relying on the throw
- Serialize open/close calls
- Prompt users to reset denied permissions
When it happens
Trigger: Recorder.open failing due to denied mic permission (UserNotAllow), missing/inaccessible audio input, insecure origin (non-HTTPS), 'open被取消'/'open被中断' from the library's open/close lock, or envCheck failure.
Common situations: User denies the permission prompt; another app holds the mic exclusively; page served over http in production; calling open after close triggered the lock-cancel path.
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
- msg (dynamic; logged as '无法录音:'+msg and shown via…
- errMsg (dynamic; logged as…
- code (dynamic; from e.name||e.message, logged as '请求录音权限错误')
- 未开始录音
- 未采集到录音
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/90d2805c8b738d09.
Report an issue: GitHub.
Appendix: source
Thrown at console/frontend/src/utils/record/record.js:331
_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)