File tree 5 files changed +34
-10
lines changed
5 files changed +34
-10
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' tuf-js ' : minor
3
+ ---
4
+
5
+ Deprecates in ` fetchRetries ` config option in the ` UpdaterOptions ` interface in favor of the new ` fetchRetry ` option.
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ describe('Updater', () => {
21
21
metadataBaseUrl : `${ baseURL } /metadata` ,
22
22
targetBaseUrl : `${ baseURL } /targets` ,
23
23
config : {
24
- fetchRetries : 0 ,
24
+ fetchRetry : 0 ,
25
25
fetchTimeout : 1000 ,
26
26
} ,
27
27
} ;
Original file line number Diff line number Diff line change 1
- export const defaultConfig = {
1
+ import type { MakeFetchHappenOptions } from 'make-fetch-happen' ;
2
+
3
+ export type Config = {
4
+ maxRootRotations : number ;
5
+ maxDelegations : number ;
6
+ rootMaxLength : number ;
7
+ timestampMaxLength : number ;
8
+ snapshotMaxLength : number ;
9
+ targetsMaxLength : number ;
10
+ prefixTargetsWithHash : boolean ;
11
+ fetchTimeout : number ;
12
+ // deprecated use fetchRetry instead
13
+ fetchRetries : number | undefined ;
14
+ fetchRetry : MakeFetchHappenOptions [ 'retry' ] ;
15
+ } ;
16
+
17
+ export const defaultConfig : Config = {
2
18
maxRootRotations : 32 ,
3
19
maxDelegations : 32 ,
4
20
rootMaxLength : 512000 , //bytes
@@ -7,7 +23,6 @@ export const defaultConfig = {
7
23
targetsMaxLength : 5000000 , // bytes
8
24
prefixTargetsWithHash : true ,
9
25
fetchTimeout : 100000 , // milliseconds
10
- fetchRetries : 2 ,
26
+ fetchRetries : undefined ,
27
+ fetchRetry : 2 ,
11
28
} ;
12
-
13
- export type Config = typeof defaultConfig ;
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import util from 'util';
6
6
import { DownloadHTTPError , DownloadLengthMismatchError } from './error' ;
7
7
import { withTempFile } from './utils/tmpfile' ;
8
8
9
+ import type { MakeFetchHappenOptions } from 'make-fetch-happen' ;
10
+
9
11
const log = debug ( 'tuf:fetch' ) ;
10
12
11
13
type DownloadFileHandler < T > = ( file : string ) => Promise < T > ;
@@ -74,26 +76,28 @@ export abstract class BaseFetcher implements Fetcher {
74
76
}
75
77
}
76
78
79
+ type Retry = MakeFetchHappenOptions [ 'retry' ] ;
80
+
77
81
interface FetcherOptions {
78
82
timeout ?: number ;
79
- retries ?: number ;
83
+ retry ?: Retry ;
80
84
}
81
85
82
86
export class DefaultFetcher extends BaseFetcher {
83
87
private timeout ?: number ;
84
- private retries ?: number ;
88
+ private retry ?: Retry ;
85
89
86
90
constructor ( options : FetcherOptions = { } ) {
87
91
super ( ) ;
88
92
this . timeout = options . timeout ;
89
- this . retries = options . retries ;
93
+ this . retry = options . retry ;
90
94
}
91
95
92
96
public override async fetch ( url : string ) : Promise < NodeJS . ReadableStream > {
93
97
log ( 'GET %s' , url ) ;
94
98
const response = await fetch ( url , {
95
99
timeout : this . timeout ,
96
- retry : this . retries ,
100
+ retry : this . retry ,
97
101
} ) ;
98
102
99
103
if ( ! response . ok || ! response ?. body ) {
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ export class Updater {
62
62
fetcher ||
63
63
new DefaultFetcher ( {
64
64
timeout : this . config . fetchTimeout ,
65
- retries : this . config . fetchRetries ,
65
+ retry : this . config . fetchRetries ?? this . config . fetchRetry ,
66
66
} ) ;
67
67
}
68
68
You can’t perform that action at this time.
0 commit comments