File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import got from 'got'
2- import { Failbot , HTTPBackend , LogBackend } from '@github/failbot'
2+ import { Failbot , HTTPBackend } from '@github/failbot'
33
44const HAYSTACK_APP = 'docs'
55
6+ async function retryingGot ( url , args ) {
7+ return got (
8+ url ,
9+ Object . assign ( { } , args , {
10+ // With the timeout at 3000 (milliseconds) and the retry.limit
11+ // at 4 (times), the total worst-case is:
12+ // 3000 * 4 + 1000 + 2000 + 3000 + 4000 + 8000 = 30 seconds
13+ timeout : 3000 ,
14+ retry : {
15+ // This means it will wait...
16+ // 1. 1000ms
17+ // 2. 2000ms
18+ // 3. 4000ms
19+ // 4. 8000ms
20+ // 5. give up!
21+ //
22+ // From the documentation:
23+ //
24+ // Delays between retries counts with function
25+ // 1000 * Math.pow(2, retry - 1) + Math.random() * 100,
26+ // where retry is attempt number (starts from 1).
27+ //
28+ limit : 4 ,
29+ } ,
30+ } )
31+ )
32+ }
33+
634export function report ( error , metadata ) {
735 // If there's no HAYSTACK_URL set, bail early
836 if ( ! process . env . HAYSTACK_URL ) return
937
1038 const backends = [
1139 new HTTPBackend ( {
1240 haystackURL : process . env . HAYSTACK_URL ,
13- fetchFn : got ,
41+ fetchFn : retryingGot ,
1442 } ) ,
1543 ]
16- if ( process . env . NODE_ENV !== 'test' ) {
17- backends . push ( new LogBackend ( { log : console . log . bind ( console ) } ) )
18- }
1944 const failbot = new Failbot ( {
2045 app : HAYSTACK_APP ,
2146 backends : backends ,
You can’t perform that action at this time.
0 commit comments