Add exponential backoff retry to all downstream calls

New controller/retry.js wraps async calls with infinite retries, capped

at 30s with jitter. Applied to: TPB search, TMDB, Emby, Ollama chat,

Transmission RPC, and the status/status interval calls inherit it via

a Proxy around the Transmission client.

Also handles ollama package returning pre-parsed JSON objects.

Signed-off-by: William Mantly <wmantly@gmail.com>
This commit is contained in:
2026-07-20 14:44:41 -04:00
parent 803a6db033
commit 51e6817393
8 changed files with 147 additions and 51 deletions
+3 -8
View File
@@ -1,18 +1,13 @@
'use strict';
const conf = require('>/conf');
const { fetchWithRetry } = require('./retry');
// Ask Emby to (re)scan its libraries so a newly filed item gets indexed.
async function refresh(){
let res = await fetch(`${conf.emby.url}/Library/Refresh?api_key=${conf.emby.apiKey}`, {
let res = await fetchWithRetry(`${conf.emby.url}/Library/Refresh?api_key=${conf.emby.apiKey}`, {
method: 'POST',
});
if(!res.ok){
let error = new Error('EmbyError');
error.message = `Emby library refresh failed( ${res.status})`;
error.status = 502;
throw error;
}
}, { label: 'emby refresh' });
return true;
}