@@ -42,6 +42,7 @@ import { createTimeoutSignal } from "../common/fetch-stream";
42
42
import { unzipToDirectoryConcurrently } from "../common/unzip-concurrently" ;
43
43
import { reportUnzipProgress } from "../common/vscode/unzip-progress" ;
44
44
import { getDirectoryNamesInsidePath } from "../common/files" ;
45
+ import { Readable } from "stream" ;
45
46
46
47
// Limit to three repos when generating autofixes so not sending
47
48
// too many requests to autofix. Since we only need to validate
@@ -459,11 +460,8 @@ async function downloadPublicCommitSource(
459
460
) ;
460
461
461
462
// Set timeout
462
- const {
463
- signal,
464
- onData,
465
- dispose : disposeTimeout ,
466
- } = createTimeoutSignal ( downloadTimeout ( ) ) ;
463
+ const { signal, dispose : disposeTimeout } =
464
+ createTimeoutSignal ( downloadTimeout ( ) ) ;
467
465
468
466
// Fetch the url
469
467
let response : Response ;
@@ -507,25 +505,18 @@ async function downloadPublicCommitSource(
507
505
) ;
508
506
509
507
try {
510
- const reader = body . getReader ( ) ;
511
- for ( ; ; ) {
512
- const { done, value } = await reader . read ( ) ;
513
- if ( done ) {
514
- break ;
515
- }
516
-
517
- onData ( ) ;
518
- reportProgress ( value ?. length ?? 0 ) ;
519
-
520
- await new Promise ( ( resolve , reject ) => {
521
- archiveFileStream . write ( value , ( err ) => {
522
- if ( err ) {
523
- reject ( err ) ;
524
- }
525
- resolve ( undefined ) ;
526
- } ) ;
527
- } ) ;
528
- }
508
+ const readable = Readable . fromWeb ( body ) ;
509
+ readable . on ( "data" , ( chunk ) => {
510
+ reportProgress ( chunk ?. length ?? 0 ) ;
511
+ } ) ;
512
+ await new Promise ( ( resolve , reject ) => {
513
+ readable
514
+ . pipe ( archiveFileStream )
515
+ . on ( "error" , ( err ) => {
516
+ reject ( err ) ;
517
+ } )
518
+ . on ( "finish" , ( ) => resolve ( undefined ) ) ;
519
+ } ) ;
529
520
530
521
await new Promise ( ( resolve , reject ) => {
531
522
archiveFileStream . close ( ( err ) => {
0 commit comments