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 {
149149 }
150150 }
151151
152+ let abortTimeout : number | undefined ;
153+
152154 // TODO: Can we merge signals?
153155 if ( ! context . options . signal && context . options . timeout ) {
154156 const controller = new AbortController ( ) ;
155- setTimeout ( ( ) => controller . abort ( ) , context . options . timeout ) ;
157+ abortTimeout = setTimeout ( ( ) => controller . abort ( ) , context . options . timeout ) ;
156158 context . options . signal = controller . signal ;
157159 }
158160
@@ -161,7 +163,9 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
161163 context . request ,
162164 context . options as RequestInit
163165 ) ;
166+ clearTimeout ( abortTimeout ) ;
164167 } catch ( error ) {
168+ clearTimeout ( abortTimeout ) ;
165169 context . error = error as Error ;
166170 if ( context . options . onRequestError ) {
167171 await context . options . onRequestError ( context as any ) ;
You can’t perform that action at this time.
0 commit comments