mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-16 09:11:03 +08:00
fix: report accurate is_running after trader update to stop redundant start
Live verification of the relaunch (update) branch surfaced this: the update response omitted is_running, so the launcher fired a redundant start that got 400 'Trader is already running', showing an error toast and skipping the dashboard navigation even though the relaunch succeeded. - PUT /traders/:id now reports is_running (a running trader is restarted with the new config, so it stays running). - The already-running rejection carries error_key trader.start.already_running and the shared launcher treats it as success (launch is idempotent).
This commit is contained in:
@@ -101,7 +101,16 @@ export async function launchAutopilot(
|
||||
: await api.createTrader(traderRequest)
|
||||
|
||||
if (!autopilot.is_running) {
|
||||
await api.startTrader(autopilot.trader_id)
|
||||
try {
|
||||
await api.startTrader(autopilot.trader_id)
|
||||
} catch (err) {
|
||||
// Launch is idempotent: the update path restarts a running trader
|
||||
// asynchronously, so a racing "already running" rejection is success.
|
||||
const alreadyRunning =
|
||||
err instanceof ApiError &&
|
||||
err.errorKey === 'trader.start.already_running'
|
||||
if (!alreadyRunning) throw err
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user