File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -149,10 +149,12 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
149
149
}
150
150
}
151
151
152
+ let abortTimeout : number | undefined ;
153
+
152
154
// TODO: Can we merge signals?
153
155
if ( ! context . options . signal && context . options . timeout ) {
154
156
const controller = new AbortController ( ) ;
155
- setTimeout ( ( ) => controller . abort ( ) , context . options . timeout ) ;
157
+ abortTimeout = setTimeout ( ( ) => controller . abort ( ) , context . options . timeout ) ;
156
158
context . options . signal = controller . signal ;
157
159
}
158
160
@@ -161,7 +163,9 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
161
163
context . request ,
162
164
context . options as RequestInit
163
165
) ;
166
+ clearTimeout ( abortTimeout ) ;
164
167
} catch ( error ) {
168
+ clearTimeout ( abortTimeout ) ;
165
169
context . error = error as Error ;
166
170
if ( context . options . onRequestError ) {
167
171
await context . options . onRequestError ( context as any ) ;
You can’t perform that action at this time.
0 commit comments