File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 59
59
"license" : " MIT" ,
60
60
"dependencies" : {
61
61
"@iarna/toml" : " ^2.2.5" ,
62
+ "@netlify/headers-parser" : " ^8.0.0" ,
63
+ "@netlify/redirect-parser" : " ^14.5.0" ,
62
64
"chalk" : " ^5.0.0" ,
63
65
"cron-parser" : " ^4.1.0" ,
64
66
"deepmerge" : " ^4.2.2" ,
73
75
"js-yaml" : " ^4.0.0" ,
74
76
"map-obj" : " ^5.0.0" ,
75
77
"netlify" : " ^13.3.3" ,
76
- "@netlify/headers-parser" : " ^8.0.0" ,
77
- "@netlify/redirect-parser" : " ^14.5.0" ,
78
78
"node-fetch" : " ^3.3.1" ,
79
79
"omit.js" : " ^2.0.2" ,
80
80
"p-locate" : " ^6.0.0" ,
81
81
"path-type" : " ^5.0.0" ,
82
+ "retry" : " ^0.13.1" ,
82
83
"tomlify-j0.4" : " ^3.0.0" ,
83
84
"validate-npm-package-name" : " ^4.0.0" ,
84
85
"yargs" : " ^17.6.0"
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { throwUserError } from '../error.js'
7
7
import { ERROR_CALL_TO_ACTION } from '../log/messages.js'
8
8
import { IntegrationResponse } from '../types/api.js'
9
9
import { ModeOption , TestOptions } from '../types/options.js'
10
+ import retry from "retry"
10
11
11
12
type GetSiteInfoOpts = {
12
13
siteId : string
@@ -149,15 +150,28 @@ const getIntegrations = async function ({
149
150
}
150
151
}
151
152
152
- const response = await fetch ( url , requestOptions )
153
- if ( ! response . ok ) {
154
- throw new Error ( `Unexpected status code ${ response . status } from fetching extensions` )
155
- }
156
- const bodyText = await response . text ( )
153
+ const MAX_RETRY = 3
154
+
155
+ const retryOperation = retry . operation ( {
156
+ retries : MAX_RETRY ,
157
+ minTimeout : 1 * 500 ,
158
+ maxTimeout : 5 * 1000 ,
159
+ } )
160
+
161
+ let bodyText
162
+
163
+ retryOperation . attempt ( async ( ) => {
164
+ const response = await fetch ( url , requestOptions )
165
+ if ( ! response . ok ) {
166
+ throw new Error ( `Unexpected status code ${ response . status } from fetching extensions` )
167
+ }
168
+
169
+ bodyText = await response . text ( )
170
+ } )
171
+
157
172
if ( bodyText === '' ) {
158
173
return [ ]
159
174
}
160
-
161
175
const integrations = await JSON . parse ( bodyText )
162
176
return Array . isArray ( integrations ) ? integrations : [ ]
163
177
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments