Skip to content

Commit aae870c

Browse files
committed
test: retry "Something went wrong" GraphQL error
1 parent 659b0f4 commit aae870c

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

test/retry.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,62 @@ describe("Automatic Retries", function () {
265265

266266
expect(caught).toEqual(testStatuses.length);
267267
});
268+
269+
it.only('Should retry "Something went wrong" GraphQL error', async function () {
270+
const octokit = new TestOctokit();
271+
272+
const result = await octokit.graphql({
273+
query: `query {
274+
viewer {
275+
login
276+
}
277+
}`,
278+
request: {
279+
responses: [
280+
{
281+
status: 200,
282+
headers: {},
283+
data: {
284+
errors: [
285+
{
286+
message:
287+
// the `0000:0000:0000000:0000000:00000000` part is variable, it's the request ID provided by GitHub
288+
"Something went wrong while executing your query. Please include `0000:0000:0000000:0000000:00000000` when reporting this issue.",
289+
},
290+
],
291+
},
292+
},
293+
{
294+
status: 200,
295+
headers: {},
296+
data: {
297+
data: {
298+
viewer: {
299+
login: "gr2m",
300+
},
301+
},
302+
},
303+
},
304+
],
305+
retries: 1,
306+
},
307+
});
308+
309+
expect(result).toStrictEqual({
310+
viewer: {
311+
login: "gr2m",
312+
},
313+
});
314+
expect(octokit.__requestLog).toStrictEqual([
315+
"START POST /graphql",
316+
"START POST /graphql",
317+
"END POST /graphql",
318+
]);
319+
320+
expect(
321+
octokit.__requestTimings[1] - octokit.__requestTimings[0]
322+
).toBeLessThan(20);
323+
});
268324
});
269325

270326
describe("errorRequest", function () {

0 commit comments

Comments
 (0)