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
+5 -1
View File
@@ -7,6 +7,7 @@ const ollama = require('>/controller/ollama');
const tmdb = require('>/controller/tmdb');
const emby = require('>/controller/emby');
const ps = require('>/controller/pubsub');
const { withRetry } = require('>/controller/retry');
const VIDEO_EXT = new Set(['.mkv', '.mp4', '.avi', '.m4v', '.ts', '.wmv', '.mov']);
const SUB_EXT = new Set(['.srt', '.ass', '.ssa', '.sub', '.vtt', '.idx']);
@@ -57,7 +58,10 @@ function buildExtractPrompt(today){
async function llmExtract({ name, category, files }){
let today = new Date().toISOString().slice(0, 10);
let user = JSON.stringify({ name, type: category, files });
return await ollama.chatJSON(buildExtractPrompt(today), user);
return await withRetry(
() => ollama.chatJSON(buildExtractPrompt(today), user),
{ label: 'ollama llmExtract' }
);
}
// Parse + canonicalize. Returns a metadata object, or one carrying `organizeError`