Skip to content

Commit

Permalink
feat(gatsby-plugin-benchmark-reporting): allow passing a secret to be…
Browse files Browse the repository at this point in the history
…nchmark reporting endpoint (#22108)

* pass x-benchmark-secret in headers with call to benchmarks api

* exit on 401 if we receive one
  • Loading branch information
abhiaiyer91 authored Mar 9, 2020
1 parent b28c27a commit 5bd889e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/gatsby-plugin-benchmark-reporting/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,17 @@ class BenchMeta {
method: `POST`,
headers: {
"content-type": `application/json`,
// "user-agent": this.getUserAgent(),
"x-benchmark-secret": process.env.BENCHMARK_REPORTING_SECRET,
},
body: json,
}).then(res => {
lastStatus = res.status
if (lastStatus === 500) {
reportInfo(`Got 500 response, waiting for text`)
if ([401, 500].includes(lastStatus)) {
reportInfo(`Got ${lastStatus} response, waiting for text`)
res.text().then(content => {
reportError(
`Response error`,
new Error(`Server responded with a 500 error: ${content}`)
new Error(`Server responded with a ${lastStatus} error: ${content}`)
)
process.exit(1)
})
Expand Down

0 comments on commit 5bd889e

Please sign in to comment.