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 -3
View File
@@ -1,6 +1,7 @@
'use strict';
const conf = require('>/conf');
const { fetchJSONWithRetry } = require('./retry');
// Resolution rank so we can compare "what you own" against a candidate release.
function rankFromWidth(w){
@@ -25,9 +26,8 @@ function labelFromRank(rank){ return ['', '480p', '720p', '1080p', '4k'][rank] |
async function embyGet(pathAndQuery){
let sep = pathAndQuery.includes('?') ? '&' : '?';
let res = await fetch(`${conf.emby.url}${pathAndQuery}${sep}api_key=${conf.emby.apiKey}`);
if(!res.ok) throw new Error(`Emby ${res.status}`);
return await res.json();
let res = await fetchJSONWithRetry(`${conf.emby.url}${pathAndQuery}${sep}api_key=${conf.emby.apiKey}`, {}, { label: `emby ${pathAndQuery.split('?')[0]}` });
return res;
}
// Is this movie already in the library, and at what best quality? Never throws — an