Skip to content

Commit 8967643

Browse files
committed
fix: Remove unnecessary merging of AbortSignal to avoid overhead
1 parent bbfb99d commit 8967643

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/adapters/config/http-config.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ export interface MastoHttpConfigProps {
1616
readonly accessToken?: string;
1717

1818
/**
19-
* Timeout configuration
19+
* Timeout milliseconds for the fetch request.
2020
*
21-
* - A number sets the timeout in milliseconds.
22-
*
23-
* Defaults to 1000 * 300 = 300 seconds.
21+
* Defaults to browser's default timeout.
2422
*/
2523
readonly timeout?: number;
2624

@@ -95,6 +93,6 @@ export class HttpConfigImpl implements HttpConfig {
9593
signals.push(signal);
9694
}
9795

98-
return mergeAbortSignals(signals);
96+
return signals.length === 1 ? signals[0] : mergeAbortSignals(signals);
9997
}
10098
}

src/adapters/http/http-native-impl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ export class HttpNativeImpl extends BaseHttp implements Http {
115115
);
116116
}
117117

118+
// TODO: Remove this handling when `AbortSignal.any` is shipped
118119
// eslint-disable-next-line @typescript-eslint/no-explicit-any
119-
if (error != undefined && (error as any).name === "AbortError") {
120+
if (error != undefined && (error as any).name === "TimeoutError") {
120121
return new MastoTimeoutError(`Request timed out`, { cause: error });
121122
}
122123

0 commit comments

Comments
 (0)