chore: cv多了(

This commit is contained in:
pk5ls20 2024-10-25 05:17:01 +08:00
parent d3405edd42
commit aa67a2b71c
No known key found for this signature in database
GPG Key ID: 6370ED7A169F493A

View File

@ -27,7 +27,7 @@ abstract class HighwayUploader {
protected timeout(): Promise<void> {
return new Promise<void>((_, reject) => {
setTimeout(() => {
reject(new Error(`[Highway] tcpUpload timeout after ${this.trans.timeout}s`));
reject(new Error(`[Highway] timeout after ${this.trans.timeout}s`));
}, (this.trans.timeout ?? Infinity) * 1000
);
})
@ -137,9 +137,9 @@ export class HighwayTcpUploader extends HighwayUploader {
reject(new Error(`[Highway] tcpUpload readable error: ${err}`));
});
});
const timeout = this.timeout().then(() => {
const timeout = this.timeout().catch((err) => {
controller.abort();
throw new Error('Highway TCP Upload timed out');
throw new Error(err.message);
});
await Promise.race([upload, timeout]);
}
@ -164,9 +164,9 @@ export class HighwayHttpUploader extends HighwayUploader {
offset += block.length;
}
})();
const timeout = this.timeout().then(() => {
const timeout = this.timeout().catch((err) => {
controller.abort();
throw new Error('Highway HTTP Upload timed out');
throw new Error(err.message);
});
await Promise.race([upload, timeout]);
}