Skip to content

Commit 8ec6429

Browse files
committed
fix(logs): preserve runtime errors and explain rebalance replay
Signed-off-by: TIANHE <[email protected]>
1 parent 39cd1a6 commit 8ec6429

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎src/locales/lang/strategy-live-risk.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,23 @@ Object.entries(gridAuditLocales).forEach(([localeKey, values]) => {
10491049
})
10501050
})
10511051

1052+
const rebalanceReplayLocales = {
1053+
'en-US': "This rebalance is already recorded; duplicate submission was skipped. Existing orders will continue reconciliation. If the previous attempt was interrupted, review any unqueued legs.",
1054+
'zh-CN': "本次调仓已有记录,已跳过重复提交;已有订单继续对账。如上次执行中断,请核查尚未入队的部分。",
1055+
'zh-TW': "本次調倉已有記錄,已跳過重複提交;已有訂單繼續對帳。如上次執行中斷,請核查尚未入隊的部分。",
1056+
'ja-JP': "このリバランスは記録済みのため、重複送信をスキップしました。既存注文の照合は継続します。前回の処理が中断された場合は、未登録の注文を確認してください。",
1057+
'ko-KR': "이미 기록된 리밸런싱이므로 중복 제출을 건너뛰었습니다. 기존 주문 대조는 계속됩니다. 이전 실행이 중단됐다면 대기열에 등록되지 않은 주문을 확인하세요.",
1058+
'de-DE': "Diese Umschichtung ist bereits erfasst; die erneute Übermittlung wurde übersprungen. Bestehende Aufträge werden weiter abgeglichen. Prüfen Sie bei einem früheren Abbruch die noch nicht eingereihten Aufträge.",
1059+
'fr-FR': "Ce rééquilibrage est déjà enregistré ; le nouvel envoi a été ignoré. Le rapprochement des ordres existants continue. Si la tentative précédente a été interrompue, vérifiez les ordres non mis en file.",
1060+
'ru-RU': "Эта ребалансировка уже записана; повторная отправка пропущена. Сверка существующих ордеров продолжается. Если предыдущая попытка прервалась, проверьте ордера, не попавшие в очередь.",
1061+
'vi-VN': "Lần tái cân bằng này đã được ghi nhận; đã bỏ qua gửi trùng. Các lệnh hiện có tiếp tục được đối soát. Nếu lần trước bị gián đoạn, hãy kiểm tra các lệnh chưa vào hàng đợi.",
1062+
'th-TH': "บันทึกการปรับพอร์ตครั้งนี้แล้ว จึงข้ามการส่งซ้ำ คำสั่งเดิมจะยังได้รับการกระทบยอด หากครั้งก่อนถูกขัดจังหวะ โปรดตรวจสอบคำสั่งที่ยังไม่ได้เข้าคิว",
1063+
'ar-SA': "سُجلت إعادة الموازنة هذه بالفعل، لذا تم تخطي الإرسال المكرر. تستمر مطابقة الأوامر الحالية. إذا توقفت المحاولة السابقة، فراجع الأوامر التي لم تدخل قائمة الانتظار."
1064+
}
1065+
Object.entries(rebalanceReplayLocales).forEach(([localeKey, message]) => {
1066+
healthReasonTargets[localeKey]['strategyV2.rebalanceReplaySkipped'] = message
1067+
})
1068+
10521069
export default {
10531070
'en-US': locale,
10541071
'zh-CN': zhCN,

‎src/utils/strategyLogs.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ export const translateStrategyRuntimeMessage = (message, translate, exchangeErro
8888
match = text.match(/^Exchange order failed \(([^)]+)\):/i)
8989
if (match) return localize('trading-assistant.logs.message.exchangeOrderFailed', { context: match[1] }) || text
9090

91-
match = text.match(/^Runtime cycle failed:/i)
92-
if (match) return localize('trading-assistant.logs.message.runtimeCycleFailed') || text
91+
match = text.match(/^Runtime cycle failed:\s*([\s\S]*)/i)
92+
if (match) {
93+
const summary = localize('trading-assistant.logs.message.runtimeCycleFailed')
94+
return summary ? `${summary} ${match[1]}`.trim() : text
95+
}
9396

9497
match = text.match(/^Order queued:\s*(\w+)\s+(\S+)\s+quantity=([^\s]+)[\s\S]*?pending_id=([^\s]+)/i)
9598
if (match) {

‎tests/unit/strategyRuntimeMessages.test.mjs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
import assert from 'node:assert/strict'
22
import test from 'node:test'
3+
34
import messages from '../../src/locales/lang/strategy-live-risk.js'
45
import { translateStrategyRuntimeMessage } from '../../src/utils/strategyLogs.js'
56

7+
test('runtime failures retain the actual cause and replay notices are localized', () => {
8+
const key = 'strategyV2.rebalanceReplaySkipped'
9+
for (const locale of Object.keys(messages)) {
10+
const translate = value => messages[locale][value] || value
11+
const raw = 'Runtime cycle failed: strategyV2.rebalanceBatchClosed'
12+
assert.match(translateStrategyRuntimeMessage(raw, translate), /strategyV2.rebalanceBatchClosed/)
13+
const multiline = 'Runtime cycle failed: example error\ncontext detail'
14+
assert.match(translateStrategyRuntimeMessage(multiline, translate), /example error\ncontext detail/)
15+
assert.equal(translateStrategyRuntimeMessage(raw, value => value), raw)
16+
assert.ok(messages[locale][key])
17+
const replay = translateStrategyRuntimeMessage(`${key}:2026-11-25T14:35:49Z`, translate)
18+
assert.ok(replay.includes(messages[locale][key]))
19+
assert.ok(replay.includes('2026-11-25T14:35:49Z'))
20+
}
21+
})
22+
623
test('Gate stock account environment errors are readable in logs', () => {
724
const key = 'strategyV2.gateStockTestnetUnsupported'
825
for (const locale of ['en-US', 'zh-CN']) {

0 commit comments

Comments
 (0)