lab4: e2e вложений, отказы S3/PG, исправления потока загрузки

This commit is contained in:
2026-10-22 22:37:05 +03:00
parent 6fcc623447
commit 7de3012b46
7 changed files with 778 additions and 12 deletions
@@ -232,6 +232,11 @@ export class AttachmentsService {
})(),
);
// A failing body must abort the PUT at once: the SDK does not end a
// request whose Content-Length can no longer be satisfied, it would
// hang until the request timeout. The error itself is reported via
// `rejection`; the listener also keeps a late error from crashing us.
readable.on('error', () => controller.abort());
let claimed = false;
try {
await this.storage.putStream(
@@ -258,6 +263,7 @@ export class AttachmentsService {
this.metrics.increment('attachments.upload.created');
return toAttachment(row);
} catch (error) {
readable.destroy();
if (!claimed) await this.compensate(id, key);
throw this.mapUploadError(rejection ?? error, timedOut);
}