fix(github): Shrink GraphQL pagination for ExternalHostError (#18435)

This commit is contained in:
Sergei Zharinov
2022-10-20 19:53:45 +03:00
committed by GitHub
parent fb09a30b5e
commit d4709ec761
+4 -6
View File
@@ -1,6 +1,6 @@
import AggregateError from 'aggregate-error';
import { TimeoutError } from 'got';
import { logger } from '../../../logger';
import { ExternalHostError } from '../../../types/errors/external-host-error';
import * as memCache from '../../cache/memory';
import type {
GithubGraphqlResponse,
@@ -30,13 +30,11 @@ function isUnknownGraphqlError(err: Error): boolean {
return message.startsWith('Something went wrong while executing your query.');
}
function isTimeoutError(err: Error): err is TimeoutError {
return err instanceof TimeoutError;
}
function canBeSolvedByShrinking(err: Error): boolean {
const errors: Error[] = err instanceof AggregateError ? [...err] : [err];
return errors.some((e) => isTimeoutError(e) || isUnknownGraphqlError(e));
return errors.some(
(e) => err instanceof ExternalHostError || isUnknownGraphqlError(e)
);
}
export class GithubGraphqlDatasourceHelper<