@upyo/resend 0.5.0-dev.164 → 0.5.0-dev.168
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 +18 -6
- package/dist/index.js +18 -6
- package/package.json +2 -2
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;
|
|
@@ -212,21 +213,32 @@ function combineSignals(timeoutSignal, externalSignal) {
|
|
|
212
213
|
cleanup: () => {}
|
|
213
214
|
};
|
|
214
215
|
const controller = new AbortController();
|
|
215
|
-
const abort = () =>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
const abort = (signal) => {
|
|
217
|
+
controller.abort(getAbortReason(signal));
|
|
218
|
+
};
|
|
219
|
+
const abortTimeout = () => abort(timeoutSignal);
|
|
220
|
+
const abortExternal = () => abort(externalSignal);
|
|
221
|
+
timeoutSignal.addEventListener("abort", abortTimeout, { once: true });
|
|
222
|
+
externalSignal.addEventListener("abort", abortExternal, { once: true });
|
|
223
|
+
if (timeoutSignal.aborted) abortTimeout();
|
|
224
|
+
else if (externalSignal.aborted) abortExternal();
|
|
219
225
|
return {
|
|
220
226
|
signal: controller.signal,
|
|
221
227
|
cleanup: () => {
|
|
222
|
-
timeoutSignal.removeEventListener("abort",
|
|
223
|
-
externalSignal.removeEventListener("abort",
|
|
228
|
+
timeoutSignal.removeEventListener("abort", abortTimeout);
|
|
229
|
+
externalSignal.removeEventListener("abort", abortExternal);
|
|
224
230
|
}
|
|
225
231
|
};
|
|
226
232
|
}
|
|
233
|
+
function getAbortReason(signal) {
|
|
234
|
+
return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
235
|
+
}
|
|
227
236
|
function isAbortError$1(error) {
|
|
228
237
|
return error instanceof Error && error.name === "AbortError";
|
|
229
238
|
}
|
|
239
|
+
function isCallerAbort(error, signal) {
|
|
240
|
+
return signal?.aborted === true && (isAbortError$1(error) || error === signal.reason);
|
|
241
|
+
}
|
|
230
242
|
function truncateErrorBody(text) {
|
|
231
243
|
return text.length > 500 ? `${text.slice(0, 500)}...` : text;
|
|
232
244
|
}
|
package/dist/index.js
CHANGED
|
@@ -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;
|
|
@@ -189,21 +190,32 @@ function combineSignals(timeoutSignal, externalSignal) {
|
|
|
189
190
|
cleanup: () => {}
|
|
190
191
|
};
|
|
191
192
|
const controller = new AbortController();
|
|
192
|
-
const abort = () =>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
const abort = (signal) => {
|
|
194
|
+
controller.abort(getAbortReason(signal));
|
|
195
|
+
};
|
|
196
|
+
const abortTimeout = () => abort(timeoutSignal);
|
|
197
|
+
const abortExternal = () => abort(externalSignal);
|
|
198
|
+
timeoutSignal.addEventListener("abort", abortTimeout, { once: true });
|
|
199
|
+
externalSignal.addEventListener("abort", abortExternal, { once: true });
|
|
200
|
+
if (timeoutSignal.aborted) abortTimeout();
|
|
201
|
+
else if (externalSignal.aborted) abortExternal();
|
|
196
202
|
return {
|
|
197
203
|
signal: controller.signal,
|
|
198
204
|
cleanup: () => {
|
|
199
|
-
timeoutSignal.removeEventListener("abort",
|
|
200
|
-
externalSignal.removeEventListener("abort",
|
|
205
|
+
timeoutSignal.removeEventListener("abort", abortTimeout);
|
|
206
|
+
externalSignal.removeEventListener("abort", abortExternal);
|
|
201
207
|
}
|
|
202
208
|
};
|
|
203
209
|
}
|
|
210
|
+
function getAbortReason(signal) {
|
|
211
|
+
return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
212
|
+
}
|
|
204
213
|
function isAbortError$1(error) {
|
|
205
214
|
return error instanceof Error && error.name === "AbortError";
|
|
206
215
|
}
|
|
216
|
+
function isCallerAbort(error, signal) {
|
|
217
|
+
return signal?.aborted === true && (isAbortError$1(error) || error === signal.reason);
|
|
218
|
+
}
|
|
207
219
|
function truncateErrorBody(text) {
|
|
208
220
|
return text.length > 500 ? `${text.slice(0, 500)}...` : text;
|
|
209
221
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/resend",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.168",
|
|
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.
|
|
56
|
+
"@upyo/core": "0.5.0-dev.168+1e808a3a"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"tsdown": "^0.12.7",
|