Improve failover startup handling and status UI
Build and Deploy Gateway / build-and-push (push) Successful in 25s
Build and Deploy Gateway / deploy (push) Successful in 6s

This commit is contained in:
2026-08-19 20:24:04 +03:00
parent cedd31cc16
commit 3b515ee355
10 changed files with 190 additions and 63 deletions
+3 -1
View File
@@ -364,7 +364,9 @@ test('selector activation failure rolls runtime and config back before applied t
},
});
const before = harness.snapshot();
await assert.rejects(harness.service.restart(), /selector failed/);
await assert.rejects(harness.service.restart(), (error) => (
error.code === 'PROCESS_START_FAILED' && error.cause?.message === 'selector failed'
));
assert.deepEqual(domain(harness.snapshot()), domain(before));
assert.equal(harness.events.includes('state.update'), false);
assert.deepEqual(harness.events.filter((event) => event.startsWith('selector.')), ['selector.primary', 'selector.primary']);
@@ -0,0 +1,19 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createSingboxSelectorService } from '../../dist/server/services/singboxSelectorService.js';
test('selector waits for the sing-box API after a fresh process start', async () => {
let attempts = 0;
const service = createSingboxSelectorService({
port: 0,
send: async (method) => {
attempts += 1;
if (attempts < 3) throw Object.assign(new Error('not ready'), { code: 'ECONNREFUSED' });
return method === 'GET' ? { now: 'channel-primary' } : {};
},
});
assert.deepEqual(await service.select('primary'), { role: 'primary' });
assert.equal(attempts, 4);
});