@@ -402,6 +402,7 @@ func downloadNode(ctx context.Context, version, target string, cfg InstallConfig
402402 if ! fromCache && ! cfg .LocalOnly {
403403 downloaded := false
404404 var downloadEnd time.Time
405+ var lastDownloadErr error
405406 insecure := allowInsecureDownloads (cfg )
406407 mirrors := settings .Global ().NodeMirror
407408 singleMirror := len (mirrors ) == 1
@@ -422,6 +423,8 @@ func downloadNode(ctx context.Context, version, target string, cfg InstallConfig
422423 shasumURI := fmt .Sprintf ("%s/v%s/SHASUMS256.txt" , mirror , version )
423424 shasumJob , err := http .Download (shasumURI , http.DownloadConfig {Cache : true , Destination : shasumPath , AllowInsecure : insecure })
424425 if err != nil {
426+ lastDownloadErr = fmt .Errorf ("checksum %s: %w" , shasumURI , err )
427+ log .Logf ("mirror %s skipped for v%s: %v" , mirror , version , lastDownloadErr )
425428 continue
426429 }
427430
@@ -438,6 +441,12 @@ func downloadNode(ctx context.Context, version, target string, cfg InstallConfig
438441 return authErr
439442 }
440443 }
444+ if ok {
445+ lastDownloadErr = describeDownloadResultFailure ("checksum" , shasumURI , result )
446+ } else {
447+ lastDownloadErr = fmt .Errorf ("checksum %s: download closed unexpectedly" , shasumURI )
448+ }
449+ log .Logf ("mirror %s skipped for v%s: %v" , mirror , version , lastDownloadErr )
441450 continue
442451 }
443452 }
@@ -446,12 +455,16 @@ func downloadNode(ctx context.Context, version, target string, cfg InstallConfig
446455 normalizedURI , err := http .NormalizeURL (uri )
447456 if err != nil {
448457 _ = os .Remove (shasumPath )
458+ lastDownloadErr = fmt .Errorf ("archive %s: %w" , uri , err )
459+ log .Logf ("mirror %s skipped for v%s: %v" , mirror , version , lastDownloadErr )
449460 continue
450461 }
451462
452463 job , err := http .Download (normalizedURI , http.DownloadConfig {Destination : target , AllowInsecure : insecure })
453464 if err != nil {
454465 _ = os .Remove (shasumPath )
466+ lastDownloadErr = fmt .Errorf ("archive %s: %w" , normalizedURI , err )
467+ log .Logf ("mirror %s skipped for v%s: %v" , mirror , version , lastDownloadErr )
455468 continue
456469 }
457470
@@ -470,7 +483,7 @@ func downloadNode(ctx context.Context, version, target string, cfg InstallConfig
470483 }
471484 case result , ok := <- job .Result :
472485 if ! ok {
473- downloadErr = fmt .Errorf ("download closed unexpectedly" )
486+ downloadErr = fmt .Errorf ("archive %s: download closed unexpectedly" , normalizedURI )
474487 break downloadLoop
475488 }
476489 if result .Error != nil || result .Response == nil || ! result .Response .Success {
@@ -480,7 +493,7 @@ func downloadNode(ctx context.Context, version, target string, cfg InstallConfig
480493 break downloadLoop
481494 }
482495 }
483- downloadErr = fmt . Errorf ( "download error" )
496+ downloadErr = describeDownloadResultFailure ( "archive" , normalizedURI , result )
484497 break downloadLoop
485498 }
486499 downloadEnd = time .Now ()
@@ -498,6 +511,8 @@ func downloadNode(ctx context.Context, version, target string, cfg InstallConfig
498511 status .Downloads --
499512 return downloadErr
500513 }
514+ lastDownloadErr = downloadErr
515+ log .Logf ("mirror %s skipped for v%s: %v" , mirror , version , lastDownloadErr )
501516 continue
502517 }
503518
@@ -521,7 +536,7 @@ func downloadNode(ctx context.Context, version, target string, cfg InstallConfig
521536
522537 if ! downloaded {
523538 status .Downloads --
524- return fmt . Errorf ( "Node.js v%s not found on server/mirror" , version )
539+ return formatNodeMirrorDownloadFailure ( version , archiveName , mirrors , lastDownloadErr )
525540 }
526541
527542 if logf != nil {
0 commit comments