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
b9be8d4d
Unverified
Commit
b9be8d4d
authored
3 years ago
by
Sergei Zharinov
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(http): Destroy some got responses explicitly to avoid onCancel errors (#12533)
parent
ca45a2c2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/util/http/hooks.ts
+25
-0
25 additions, 0 deletions
lib/util/http/hooks.ts
lib/util/http/index.ts
+2
-1
2 additions, 1 deletion
lib/util/http/index.ts
with
27 additions
and
1 deletion
lib/util/http/hooks.ts
0 → 100644
+
25
−
0
View file @
b9be8d4d
// Renovate issue: https://github.com/renovatebot/renovate/issues/12127
// Got issue: https://github.com/sindresorhus/got/issues/1489
// From here: https://github.com/sindresorhus/got/issues/1489#issuecomment-805485731
import
type
{
Hooks
,
Response
}
from
'
got
'
;
function
isResponseOk
(
response
:
Response
):
boolean
{
const
{
statusCode
}
=
response
;
const
limitStatusCode
=
response
.
request
.
options
.
followRedirect
?
299
:
399
;
return
(
(
statusCode
>=
200
&&
statusCode
<=
limitStatusCode
)
||
statusCode
===
304
);
}
export
const
hooks
:
Hooks
=
{
afterResponse
:
[
(
response
:
Response
):
Response
=>
{
if
(
isResponseOk
(
response
))
{
response
.
request
.
destroy
();
}
return
response
;
},
],
};
This diff is collapsed.
Click to expand it.
lib/util/http/index.ts
+
2
−
1
View file @
b9be8d4d
...
...
@@ -8,6 +8,7 @@ import * as memCache from '../cache/memory';
import
{
clone
}
from
'
../clone
'
;
import
{
resolveBaseUrl
}
from
'
../url
'
;
import
{
applyAuthorization
,
removeAuthorization
}
from
'
./auth
'
;
import
{
hooks
}
from
'
./hooks
'
;
import
{
applyHostRules
}
from
'
./host-rules
'
;
import
{
getQueue
}
from
'
./queue
'
;
import
type
{
...
...
@@ -98,7 +99,7 @@ async function gotRoutine<T>(
// Cheat the TS compiler using `as` to pick a specific overload.
// Otherwise it doesn't typecheck.
const
resp
=
await
got
<
T
>
(
url
,
options
as
GotJSONOptions
);
const
resp
=
await
got
<
T
>
(
url
,
{
...
options
,
hooks
}
as
GotJSONOptions
);
const
duration
=
resp
.
timings
.
phases
.
total
||
/* istanbul ignore next: can't be tested */
0
;
...
...
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