Close post-upload and admission race gaps

Treat fallback result fetch and body failures as uncertain Doodstream commits, and coordinate interval timing with slot acquisition so upload starts remain spaced without occupying another host's global slot during the wait.
This commit is contained in:
Sucukdeluxe
2026-08-14 00:07:27 +02:00
parent 28094414a8
commit 0845016efe
4 changed files with 117 additions and 13 deletions
+32
View File
@@ -329,3 +329,35 @@ test('redirect fetch failure after upload is marked as an uncertain remote commi
fs.rmSync(root, { recursive: true, force: true });
}
});
test('fallback form fetch failure after upload is marked as an uncertain remote commit', async () => {
const up = new DoodstreamUploader();
up._fetch = async () => {
throw new Error('fallback request failed');
};
await assert.rejects(
() => up._parseUploadResponse('<form action="https://doodstream.com/result"></form>'),
(err) => {
assert.equal(err.remoteCommitUncertain, true);
assert.equal(err.diagnostic.phase, 'upload-result-submit');
return true;
}
);
});
test('fallback form body failure after upload is marked as an uncertain remote commit', async () => {
const up = new DoodstreamUploader();
up._fetch = async () => ({
text: async () => {
throw new Error('fallback body failed');
}
});
await assert.rejects(
() => up._parseUploadResponse('<form action="https://doodstream.com/result"></form>'),
(err) => {
assert.equal(err.remoteCommitUncertain, true);
assert.equal(err.diagnostic.phase, 'upload-result-submit');
return true;
}
);
});