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:
+3
-8
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user