fix(protocol): improve upload recovery and time limits

Apply configurable idle and total transfer deadlines, cover supplied upload candidates, and retain recent endpoint outcomes per account and upload type. Preserve failed action responses and resource cleanup.

Refs #637
This commit is contained in:
DrSmoothl committed 2026-11-07 14:10:56 +08:00
1 parent f2ade5603f
commit 6c8866b108
10 files changed
+760 -41

No files matched your search

@@ -0,0 +1,33 @@
import { describe, expect, it } from 'vitest';
import { highwayUploadTimeouts } from '../../src/highway/upload-settings';
describe('highway upload timeouts', () => {
it('retains the idle default and supplies a finite whole-file deadline', () => {
expect(highwayUploadTimeouts({})).toEqual({ idleMs: 30_000, totalMs: 1_800_000 });
});
it('reads independent millisecond budgets without clamping', () => {
expect(
highwayUploadTimeouts({
SNOWLUMA_HIGHWAY_UPLOAD_IDLE_TIMEOUT_MS: ' 5000 ',
SNOWLUMA_HIGHWAY_UPLOAD_TIMEOUT_MS: '120000',
}),
).toEqual({ idleMs: 5000, totalMs: 120000 });
expect(highwayUploadTimeouts({ SNOWLUMA_HIGHWAY_UPLOAD_TIMEOUT_MS: '1' }).totalMs).toBe(1);
expect(
highwayUploadTimeouts({ SNOWLUMA_HIGHWAY_UPLOAD_TIMEOUT_MS: '2147483647' }).totalMs,
).toBe(2147483647);
});
it.each(['', ' ', '0', '-1', '1.5', 'NaN', 'Infinity', '1e3', '200ms', '2147483648'])(
'rejects invalid configuration %j',
(value) => {
for (const name of [
'SNOWLUMA_HIGHWAY_UPLOAD_IDLE_TIMEOUT_MS',
'SNOWLUMA_HIGHWAY_UPLOAD_TIMEOUT_MS',
]) {
expect(() => highwayUploadTimeouts({ [name]: value })).toThrow(name);
}
},
);
});