From 167a8bf88193aad7391e005a9bb8ca9b9281f4ee Mon Sep 17 00:00:00 2001 From: Bjarn Bronsveld Date: Fri, 20 Feb 2026 10:58:54 +0100 Subject: [PATCH] fix: moved `this.reset()` to a `finally` block to guarantee cleanup even if the send operation fails. --- src/endpoints/email.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/endpoints/email.ts b/src/endpoints/email.ts index fc94ebe..b756ed2 100644 --- a/src/endpoints/email.ts +++ b/src/endpoints/email.ts @@ -338,11 +338,11 @@ export class EmailEndpoint extends Endpoint { ? { headers: { 'Idempotency-Key': this.idempotencyKeyValue } } : undefined; - const response = await this.httpClient.post('/send', this.payload, config); - - this.reset(); - - return response; + try { + return await this.httpClient.post('/send', this.payload, config); + } finally { + this.reset(); + } } /**