File tree 3 files changed +9
-1
lines changed
3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 10
10
fail-fast : false
11
11
matrix :
12
12
node-version :
13
- - 18
13
+ - 22
14
14
steps :
15
15
- uses : actions/checkout@v4
16
16
- uses : actions/setup-node@v4
Original file line number Diff line number Diff line change 86
86
"@typescript-eslint/no-unsafe-return" : " off" ,
87
87
"@typescript-eslint/no-unsafe-call" : " off" ,
88
88
"@typescript-eslint/naming-convention" : " off" ,
89
+ "@typescript-eslint/no-unnecessary-type-assertion" : " off" ,
89
90
"n/no-unsupported-features/node-builtins" : " off"
90
91
}
91
92
},
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ export class Ky {
36
36
37
37
// Delay the fetch so that body method shortcuts can set the Accept header
38
38
await Promise . resolve ( ) ;
39
+ // Before using ky.request, _fetch clones it and saves the clone for future retries to use.
40
+ // If retry is not needed, close the cloned request's ReadableStream for memory safety.
39
41
let response = await ky . _fetch ( ) ;
40
42
41
43
for ( const hook of ky . _options . hooks . afterResponse ) {
@@ -64,6 +66,11 @@ export class Ky {
64
66
throw error ;
65
67
}
66
68
69
+ // Now that we know a retry is not needed, close the ReadableStream of the cloned request.
70
+ if ( ! ky . request . bodyUsed ) {
71
+ await ky . request . body ?. cancel ( ) ;
72
+ }
73
+
67
74
// If `onDownloadProgress` is passed, it uses the stream API internally
68
75
if ( ky . _options . onDownloadProgress ) {
69
76
if ( typeof ky . _options . onDownloadProgress !== 'function' ) {
You can’t perform that action at this time.
0 commit comments