Skip to content

Suppress Invoke-WebRequest progress bar to speed up downloads #73

@MariusStorhaug

Description

Invoke-WebRequest renders a progress bar by default. On PowerShell 7 the progress rendering is much faster than on 5.1, but for large downloads the per-byte progress update still measurably slows the transfer — especially in non-interactive hosts (CI, terminals without ANSI support) where the rendering cost is highest and the progress bar has no value.

Install-NerdFont downloads tens of megabytes per font and dozens of fonts in an -All run, so the cumulative overhead is significant.

Request

Current experience

Invoke-WebRequest -Uri $URL -OutFile $downloadPath -RetryIntervalSec 5 -MaximumRetryCount 5

The progress bar updates frequently during each download. In automated/CI scenarios it produces no visible value and slows the transfer.

Desired experience

Downloads complete as fast as the network allows, with no progress-bar overhead inside the function. Per-font progress is still reported via the existing Write-Verbose messages, which is sufficient for user feedback.

Acceptance criteria

  • The progress bar is not rendered while Install-NerdFont is downloading
  • The user's ambient $ProgressPreference is restored after the function exits
  • No change in correctness — retries and error handling continue to work
  • Verbose / -WhatIf output is unchanged

Related


Technical decisions

Mechanism: Save and restore $ProgressPreference around the download phase rather than overriding it globally. This avoids leaking the override into the caller's session.

Scope: Apply the suppression only around the network calls, not around the whole function, so any future progress output the function emits itself is still visible.

Alternative considered: Switch to System.Net.Http.HttpClient — faster still, but a larger change. Tracked as a separate issue; this issue is the cheap win.


Implementation plan

  • In src/functions/public/Install-NerdFont.ps1, wrap the Invoke-WebRequest call in a try { $oldPref = $ProgressPreference; $ProgressPreference = 'SilentlyContinue'; ... } finally { $ProgressPreference = $oldPref } block (or equivalent)
  • Verify that -Verbose output is unaffected
  • Verify that retries still occur on transient failures

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions