forked from mtusi2026/mtusi2026lab4
lab4: e2e вложений, отказы S3/PG, исправления потока загрузки
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user