@upyo/resend 0.5.0-dev.164 → 0.5.0-dev.170

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -160,6 +160,7 @@ var ResendHttpClient = class {
160
160
  throw new Error(`Invalid JSON response from Resend API: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
161
161
  }
162
162
  } catch (error) {
163
+ if (isCallerAbort(error, options.signal)) throw error;
163
164
  lastError = error instanceof Error ? error : new Error(String(error));
164
165
  if (error instanceof ResendApiError && error.statusCode !== void 0 && error.statusCode >= 400 && error.statusCode < 500) throw error;
165
166
  if (error instanceof Error && error.name === "AbortError") throw error;
@@ -185,7 +186,7 @@ var ResendHttpClient = class {
185
186
  for (const [key, value] of Object.entries(this.config.headers)) headers.set(key, value);
186
187
  const controller = new AbortController();
187
188
  const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
188
- const combinedSignal = combineSignals(controller.signal, options.signal);
189
+ const combinedSignal = (0, __upyo_core.combineSignals)(controller.signal, options.signal);
189
190
  try {
190
191
  const response = await fetch(url, {
191
192
  ...options,
@@ -202,31 +203,12 @@ var ResendHttpClient = class {
202
203
  }
203
204
  }
204
205
  };
205
- function combineSignals(timeoutSignal, externalSignal) {
206
- if (externalSignal == null) return {
207
- signal: timeoutSignal,
208
- cleanup: () => {}
209
- };
210
- if (typeof AbortSignal.any === "function") return {
211
- signal: AbortSignal.any([timeoutSignal, externalSignal]),
212
- cleanup: () => {}
213
- };
214
- const controller = new AbortController();
215
- const abort = () => controller.abort();
216
- timeoutSignal.addEventListener("abort", abort, { once: true });
217
- externalSignal.addEventListener("abort", abort, { once: true });
218
- if (timeoutSignal.aborted || externalSignal.aborted) controller.abort();
219
- return {
220
- signal: controller.signal,
221
- cleanup: () => {
222
- timeoutSignal.removeEventListener("abort", abort);
223
- externalSignal.removeEventListener("abort", abort);
224
- }
225
- };
226
- }
227
206
  function isAbortError$1(error) {
228
207
  return error instanceof Error && error.name === "AbortError";
229
208
  }
209
+ function isCallerAbort(error, signal) {
210
+ return signal?.aborted === true && (isAbortError$1(error) || error === signal.reason);
211
+ }
230
212
  function truncateErrorBody(text) {
231
213
  return text.length > 500 ? `${text.slice(0, 500)}...` : text;
232
214
  }
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createFailedReceipt, parseRetryAfter } from "@upyo/core";
1
+ import { combineSignals, createFailedReceipt, parseRetryAfter } from "@upyo/core";
2
2
 
3
3
  //#region src/config.ts
4
4
  /**
@@ -137,6 +137,7 @@ var ResendHttpClient = class {
137
137
  throw new Error(`Invalid JSON response from Resend API: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
138
138
  }
139
139
  } catch (error) {
140
+ if (isCallerAbort(error, options.signal)) throw error;
140
141
  lastError = error instanceof Error ? error : new Error(String(error));
141
142
  if (error instanceof ResendApiError && error.statusCode !== void 0 && error.statusCode >= 400 && error.statusCode < 500) throw error;
142
143
  if (error instanceof Error && error.name === "AbortError") throw error;
@@ -179,31 +180,12 @@ var ResendHttpClient = class {
179
180
  }
180
181
  }
181
182
  };
182
- function combineSignals(timeoutSignal, externalSignal) {
183
- if (externalSignal == null) return {
184
- signal: timeoutSignal,
185
- cleanup: () => {}
186
- };
187
- if (typeof AbortSignal.any === "function") return {
188
- signal: AbortSignal.any([timeoutSignal, externalSignal]),
189
- cleanup: () => {}
190
- };
191
- const controller = new AbortController();
192
- const abort = () => controller.abort();
193
- timeoutSignal.addEventListener("abort", abort, { once: true });
194
- externalSignal.addEventListener("abort", abort, { once: true });
195
- if (timeoutSignal.aborted || externalSignal.aborted) controller.abort();
196
- return {
197
- signal: controller.signal,
198
- cleanup: () => {
199
- timeoutSignal.removeEventListener("abort", abort);
200
- externalSignal.removeEventListener("abort", abort);
201
- }
202
- };
203
- }
204
183
  function isAbortError$1(error) {
205
184
  return error instanceof Error && error.name === "AbortError";
206
185
  }
186
+ function isCallerAbort(error, signal) {
187
+ return signal?.aborted === true && (isAbortError$1(error) || error === signal.reason);
188
+ }
207
189
  function truncateErrorBody(text) {
208
190
  return text.length > 500 ? `${text.slice(0, 500)}...` : text;
209
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upyo/resend",
3
- "version": "0.5.0-dev.164",
3
+ "version": "0.5.0-dev.170",
4
4
  "description": "Resend transport for Upyo email library",
5
5
  "keywords": [
6
6
  "email",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "sideEffects": false,
55
55
  "peerDependencies": {
56
- "@upyo/core": "0.5.0-dev.164+5e283c64"
56
+ "@upyo/core": "0.5.0-dev.170+643994fd"
57
57
  },
58
58
  "devDependencies": {
59
59
  "tsdown": "^0.12.7",