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