Skip to content

Commit b0831ed

Browse files
authored
Merge pull request #12064 from github/repo-sync
repo sync
2 parents 2142303 + d996eb1 commit b0831ed

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

lib/failbot.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
11
import got from 'got'
2-
import { Failbot, HTTPBackend, LogBackend } from '@github/failbot'
2+
import { Failbot, HTTPBackend } from '@github/failbot'
33

44
const 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+
634
export 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,

0 commit comments

Comments
 (0)