Partnership: handle empty run.php response gracefully

If run.php returns an empty body (transient nginx/PHP-FPM issue), the script
still runs via nohup. Treat empty response as ok instead of throwing a
JSON parse error that misleads the user into thinking the action failed.
This commit is contained in:
Gmer4Lfe
2026-05-30 18:45:24 -04:00
parent dfc24e37c0
commit b59b94099a
+11 -1
View File
@@ -63,7 +63,17 @@ function _vvPtRun(id, extraArgs) {
return fetch('/plugins/varaverk/api/run.php', {
method: 'POST',
body: new URLSearchParams(params)
}).then(r => r.json());
}).then(r => {
if (!r.ok) throw new Error('HTTP ' + r.status);
return r.text();
}).then(text => {
if (!text.trim()) {
// Empty body — script likely started via nohup before response was sent.
// Treat as ok; check Scheduler log for confirmation.
return {ok: true, _empty_response: true};
}
return JSON.parse(text);
});
}
function vvPtPhase1(btn, hostId) {