mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
fetchWorker: try throwing a preemptive AbortError inside the worker itself
This commit is contained in:
parent
93874df063
commit
a98bfdd0c6
1 changed files with 4 additions and 0 deletions
|
|
@ -13,6 +13,10 @@ export const FetchWorker = {
|
||||||
init: Omit<RequestInit, 'signal'>,
|
init: Omit<RequestInit, 'signal'>,
|
||||||
signal: AbortSignal | null | undefined,
|
signal: AbortSignal | null | undefined,
|
||||||
): Promise<[BodyInit, ResponseInit]> {
|
): Promise<[BodyInit, ResponseInit]> {
|
||||||
|
if (signal?.aborted) {
|
||||||
|
throw new DOMException('The signal has been aborted', 'AbortError');
|
||||||
|
}
|
||||||
|
|
||||||
logi({ level: 'debug', ns: 'ditto.fetch', state: 'started', method: init.method ?? 'GET', url });
|
logi({ level: 'debug', ns: 'ditto.fetch', state: 'started', method: init.method ?? 'GET', url });
|
||||||
|
|
||||||
const response = await safeFetch(url, { ...init, signal });
|
const response = await safeFetch(url, { ...init, signal });
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue