Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
1454b602
Unverified
Commit
1454b602
authored
2 years ago
by
Sergei Zharinov
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(github): Shrink pages for specific types of errors (#16388)
parent
b5df686f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/modules/datasource/github-releases/cache/cache-base.spec.ts
+32
-0
32 additions, 0 deletions
...dules/datasource/github-releases/cache/cache-base.spec.ts
lib/modules/datasource/github-releases/cache/cache-base.ts
+14
-0
14 additions, 0 deletions
lib/modules/datasource/github-releases/cache/cache-base.ts
with
46 additions
and
0 deletions
lib/modules/datasource/github-releases/cache/cache-base.spec.ts
+
32
−
0
View file @
1454b602
...
@@ -345,6 +345,38 @@ describe('modules/datasource/github-releases/cache/cache-base', () => {
...
@@ -345,6 +345,38 @@ describe('modules/datasource/github-releases/cache/cache-base', () => {
expect
(
packageCache
.
set
).
not
.
toHaveBeenCalled
();
expect
(
packageCache
.
set
).
not
.
toHaveBeenCalled
();
});
});
it
(
'
shrinks for some of graphql errors
'
,
async
()
=>
{
packageCache
.
get
.
mockResolvedValueOnce
({
items
:
{},
createdAt
:
t3
,
updatedAt
:
t3
,
});
responses
=
[
{
statusCode
:
200
,
headers
:
{},
body
:
{
errors
:
[
{
message
:
'
Something went wrong while executing your query.
'
},
],
},
},
resp
([{
name
:
'
v3
'
,
createdAt
:
t3
,
foo
:
'
ccc
'
}],
true
),
resp
([{
name
:
'
v2
'
,
createdAt
:
t2
,
foo
:
'
bbb
'
}],
true
),
resp
([{
name
:
'
v1
'
,
createdAt
:
t1
,
foo
:
'
aaa
'
}]),
];
const
cache
=
new
TestCache
(
http
,
{
resetDeltaMinutes
:
0
});
const
res
=
await
cache
.
getItems
({
packageName
:
'
foo/bar
'
});
expect
(
sortItems
(
res
)).
toMatchObject
([
{
version
:
'
v1
'
,
bar
:
'
aaa
'
},
{
version
:
'
v2
'
,
bar
:
'
bbb
'
},
{
version
:
'
v3
'
,
bar
:
'
ccc
'
},
]);
expect
(
packageCache
.
set
).
toHaveBeenCalled
();
});
it
(
'
finds latest release timestamp correctly
'
,
()
=>
{
it
(
'
finds latest release timestamp correctly
'
,
()
=>
{
const
cache
=
new
TestCache
(
http
);
const
cache
=
new
TestCache
(
http
);
const
ts
=
cache
.
getLastReleaseTimestamp
({
const
ts
=
cache
.
getLastReleaseTimestamp
({
...
...
This diff is collapsed.
Click to expand it.
lib/modules/datasource/github-releases/cache/cache-base.ts
+
14
−
0
View file @
1454b602
import
{
DateTime
,
DurationLikeObject
}
from
'
luxon
'
;
import
{
DateTime
,
DurationLikeObject
}
from
'
luxon
'
;
import
{
logger
}
from
'
../../../../logger
'
;
import
*
as
packageCache
from
'
../../../../util/cache/package
'
;
import
*
as
packageCache
from
'
../../../../util/cache/package
'
;
import
type
{
import
type
{
GithubGraphqlResponse
,
GithubGraphqlResponse
,
...
@@ -265,6 +266,19 @@ export abstract class AbstractGithubDatasourceCache<
...
@@ -265,6 +266,19 @@ export abstract class AbstractGithubDatasourceCache<
while
(
pagesRemained
>
0
&&
!
stopIteration
)
{
while
(
pagesRemained
>
0
&&
!
stopIteration
)
{
const
res
=
await
this
.
query
(
baseUrl
,
variables
);
const
res
=
await
this
.
query
(
baseUrl
,
variables
);
if
(
res
instanceof
Error
)
{
if
(
res
instanceof
Error
)
{
if
(
res
.
message
.
startsWith
(
'
Something went wrong while executing your query.
'
// #16343
)
&&
variables
.
count
>
30
)
{
logger
.
warn
(
`GitHub datasource cache: shrinking GraphQL page size due to error`
);
pagesRemained
*=
2
;
variables
.
count
=
Math
.
floor
(
variables
.
count
/
2
);
continue
;
}
throw
res
;
throw
res
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment