@@ -30,6 +30,7 @@ const throttledFetch = throttler(async (url: string) => {
30
30
31
31
if ( GITHUB_TOKEN && / g i t h u b .c o m / . test ( url ) ) {
32
32
headers . Authorization = `token ${ GITHUB_TOKEN } ` ;
33
+ headers . Accept = "application/vnd.github.v3+json" ;
33
34
}
34
35
35
36
if ( / b u n d l e p h o b i a / . test ( url ) ) {
@@ -39,8 +40,9 @@ const throttledFetch = throttler(async (url: string) => {
39
40
40
41
const fn = async ( ) => {
41
42
const res = await fetch ( url , { headers } ) ;
43
+ const resHeaders = Object . fromEntries ( res . headers . entries ( ) ) ;
42
44
const data = await res . json ( ) ;
43
- return { headers : JSON . parse ( JSON . stringify ( res . headers ) ) , data } ;
45
+ return { headers : resHeaders , data } ;
44
46
} ;
45
47
46
48
return await pRetry ( fn , {
@@ -56,9 +58,10 @@ const throttledFetch = throttler(async (url: string) => {
56
58
} ,
57
59
} ) ;
58
60
} catch ( err : any ) {
59
- const status = err . response ?. status ;
60
- const headers = JSON . stringify ( err . response ?. headers , null , " " ) ;
61
- log ( "failed %s - status=%s, headers=%o - %s" , url , status , headers , err ) ;
61
+ const res = err . response ;
62
+ const status = res ?. status ;
63
+ const resHeaders = Object . fromEntries ( res ?. headers . entries ( ) ) ;
64
+ log ( "failed %s - status=%s, headers=%o - %s" , url , status , resHeaders , err ) ;
62
65
throw err ;
63
66
}
64
67
} ) ;
0 commit comments