Added command timeouts for refresh-providers and sync-song

This commit is contained in:
barlind
2026-07-08 18:42:57 +02:00
parent ee33ac7ba2
commit c53fd1f384
2 changed files with 32 additions and 1 deletions
+1
View File
@@ -86,6 +86,7 @@
// operation is still completing through the provider. // operation is still completing through the provider.
const COMMAND_TIMEOUTS_MS = { const COMMAND_TIMEOUTS_MS = {
'audio-mix': { 'get-fader-value': 2100, 'set-fader-value': 2100 }, 'audio-mix': { 'get-fader-value': 2100, 'set-fader-value': 2100 },
'library': { 'refresh-providers': 15000, 'sync-song': 15000 },
'midi-input': { 'discover': 15000, 'open-source': 15000 }, 'midi-input': { 'discover': 15000, 'open-source': 15000 },
}; };
function _commandTimeoutFor(capability, commandName) { function _commandTimeoutFor(capability, commandName) {
+30
View File
@@ -78,3 +78,33 @@ test('failed no-op registrations do not block reload and rehydrate replacement',
assert.equal(result.status, 'applied'); assert.equal(result.status, 'applied');
assert.equal(result.payload.generation, 2); assert.equal(result.payload.generation, 2);
}); });
test('library long-running commands override the default handler timeout', async () => {
const window = loadCapabilities();
const api = window.feedBack.capabilities;
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
api.registerParticipant('stems', {
stems: {
roles: ['owner'],
commands: ['slow-probe'],
handlers: { 'slow-probe': async () => { await delay(300); return { outcome: 'handled' }; } },
runtime: true,
},
});
const timedOut = await api.dispatch({ capability: 'stems', command: 'slow-probe', source: 'test' });
assert.equal(timedOut.outcome, 'failed');
assert.match(timedOut.reason, /timed out after 250 ms/);
api.registerParticipant('core.library', {
library: {
roles: ['owner'],
commands: ['sync-song'],
handlers: { 'sync-song': async () => { await delay(300); return { outcome: 'handled', payload: { ok: true } }; } },
runtime: true,
},
});
const synced = await api.dispatch({ capability: 'library', command: 'sync-song', source: 'test' });
assert.equal(synced.status, 'applied');
assert.equal(synced.payload.ok, true);
});