feat: record stream interruption reasons via StreamStatus
- Add StreamStatus type (relay/common) to track stream end reason (done/timeout/client_gone/scanner_error/eof/panic/ping_fail) and accumulate soft errors during streaming via sync.Once + sync.Mutex. - Add StreamResult (relay/helper) as the callback interface: adapters call sr.Error() for soft errors, sr.Stop() for fatal, sr.Done() for normal completion. No early-return problem — multiple errors per chunk are naturally supported. - Refactor StreamScannerHandler callback from func(string) bool to func(string, *StreamResult). All 9 channel adapters updated. - Write stream_status into log other JSON field (admin-only) with status ok/error, end_reason, error_count, and error messages. - Frontend: display stream status in log detail expansion for admins.
This commit is contained in:
+26
@@ -601,6 +601,32 @@ export const useLogsData = () => {
|
||||
value: other.request_path,
|
||||
});
|
||||
}
|
||||
if (isAdminUser && other?.stream_status) {
|
||||
const ss = other.stream_status;
|
||||
const isOk = ss.status === 'ok';
|
||||
const statusLabel = isOk ? '✓ ' + t('正常') : '✗ ' + t('异常');
|
||||
let streamValue = statusLabel + ' (' + (ss.end_reason || 'unknown') + ')';
|
||||
if (ss.error_count > 0) {
|
||||
streamValue += ` [${t('软错误')}: ${ss.error_count}]`;
|
||||
}
|
||||
if (ss.end_error) {
|
||||
streamValue += ` - ${ss.end_error}`;
|
||||
}
|
||||
expandDataLocal.push({
|
||||
key: t('流状态'),
|
||||
value: streamValue,
|
||||
});
|
||||
if (Array.isArray(ss.errors) && ss.errors.length > 0) {
|
||||
expandDataLocal.push({
|
||||
key: t('流错误详情'),
|
||||
value: (
|
||||
<div style={{ maxWidth: 600, whiteSpace: 'pre-line', wordBreak: 'break-word', lineHeight: 1.6 }}>
|
||||
{ss.errors.join('\n')}
|
||||
</div>
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
if (Array.isArray(other?.po) && other.po.length > 0) {
|
||||
expandDataLocal.push({
|
||||
key: t('参数覆盖'),
|
||||
|
||||
Vendored
+5
@@ -2678,6 +2678,11 @@
|
||||
"请求结束后多退少补": "Adjust after request completion",
|
||||
"请求超时,请刷新页面后重新发起 GitHub 登录": "Request timed out, please refresh and restart GitHub login",
|
||||
"请求路径": "Request path",
|
||||
"流状态": "Stream Status",
|
||||
"流错误详情": "Stream Error Details",
|
||||
"软错误": "soft errors",
|
||||
"正常": "Normal",
|
||||
"异常": "Abnormal",
|
||||
"请求转换": "Request conversion",
|
||||
"请求预扣费额度": "Pre-deduction quota for requests",
|
||||
"请点击我": "Please click me",
|
||||
|
||||
Reference in New Issue
Block a user