@@ -88,15 +88,12 @@ function createLoader(): (
8888 return undefined
8989 }
9090
91- const controller = new AbortController ( )
92- const timeoutId = setTimeout ( ( ) => controller . abort ( ) , FETCH_TIMEOUT_MS )
93-
9491 try {
95- const response = await fetch ( url . toString ( ) , {
92+ const response = await $fetch . raw ( url . toString ( ) , {
93+ method : 'GET' ,
94+ timeout : FETCH_TIMEOUT_MS ,
9695 redirect : 'follow' ,
97- signal : controller . signal ,
9896 } )
99- clearTimeout ( timeoutId )
10097
10198 if ( response . status !== 200 ) {
10299 return undefined
@@ -115,7 +112,6 @@ function createLoader(): (
115112 content,
116113 }
117114 } catch {
118- clearTimeout ( timeoutId )
119115 return undefined
120116 }
121117 }
@@ -156,18 +152,13 @@ function createResolver(): (specifier: string, referrer: string) => string {
156152async function getTypesUrl ( packageName : string , version : string ) : Promise < string | null > {
157153 const url = `https://esm.sh/${ packageName } @${ version } `
158154
159- const controller = new AbortController ( )
160- const timeoutId = setTimeout ( ( ) => controller . abort ( ) , FETCH_TIMEOUT_MS )
161-
162155 try {
163- const response = await fetch ( url , {
156+ const response = await $ fetch. raw ( url , {
164157 method : 'HEAD' ,
165- signal : controller . signal ,
158+ timeout : FETCH_TIMEOUT_MS ,
166159 } )
167- clearTimeout ( timeoutId )
168160 return response . headers . get ( 'x-typescript-types' )
169161 } catch {
170- clearTimeout ( timeoutId )
171162 return null
172163 }
173164}
0 commit comments