Skip to content

fix(install): fall back to a GNU mirror for vcpkg asset downloads - #46

Merged
aborovsky merged 5 commits into
developfrom
fix/vcpkg-gnu-ftp-mirror
Oct 6, 2026
Merged

aborovsky merged 5 commits into
developfrom
fix/vcpkg-gnu-ftp-mirror

Conversation

@aborovsky

Copy link
Copy Markdown
Collaborator

Problem

On Windows, node-libcurl's preinstall runs a vcpkg source build. Some vcpkg
ports download their sources only from the GNU FTP network — notably the
gsasl port, whose portfile lists just:

https://ftpmirror.gnu.org/gnu/gsasl/gsasl-<ver>.tar.gz   (primary)
https://ftp.gnu.org/gnu/gsasl/gsasl-<ver>.tar.gz          (fallback)

That network is intermittently unreachable. When it times out, vcpkg exhausts
its retries on both hosts and halts the whole build:

error: Download timed out.
error: Reached maximum number of attempts, won't retry download from https://ftp.gnu.org/gnu/gsasl/gsasl-2.2.2.tar.gz.
CMake Error ... Download failed, halting portfile.

The file itself still exists — only GNU FTP's hosts are down. The identical
tarball is served across the GNU mirror network (e.g. mirrors.kernel.org,
whose copy's SHA512 matches vcpkg's expected hash exactly).

Fix

Set X_VCPKG_ASSET_SOURCES for the vcpkg install invocation to an
x-script asset provider.
vcpkg hands each asset download to a small bundled Node helper
(scripts/vcpkg-fetch-asset.js) that:

  • redirects ftpmirror.gnu.org / ftp.gnu.org /gnu/... URLs to a reachable
    GNU mirror (mirrors.kernel.org, overridable via NODE_LIBCURL_GNU_MIRROR), and
  • fetches the original URL unchanged for every other asset.

Details:

  • Non-destructive to consumers: the value is appended to any
    X_VCPKG_ASSET_SOURCES already in the environment, so a consumer's own asset
    cache still takes precedence.
  • Safe: vcpkg verifies the SHA512 of whatever the helper produces, so a
    mirror can't substitute a different file. Origin is not blocked — the helper
    itself also falls back to the original URL.
  • No new deps / portable: pure native Node.js, consistent with the other
    scripts/vcpkg-*.js. No-op in practice on non-Windows (the source build only
    runs on Windows).

This fixes the fragility at the source, so every consumer of node-libcurl
benefits — not just a single downstream CI.

Verification

Exercised the helper exactly as vcpkg invokes it
(node scripts/vcpkg-fetch-asset.js {url} {sha512} {dst}):

  • gsasl via ftpmirror.gnu.org → fetched from mirrors.kernel.org;
    SHA512 matches vcpkg's expected 62fb4a93…e703bc9.
  • gsasl via ftp.gnu.org → also redirected to the mirror.
  • non-GNU asset (a GitHub release .exe) → original URL, follows redirects,
    downloads intact.
  • node --check passes on both files; prettier-clean.

The Windows source build pulls some vcpkg dependencies (notably the gsasl
port -> gsasl-<ver>.tar.gz) only from the GNU FTP network (ftpmirror.gnu.org
/ ftp.gnu.org). That network is intermittently unreachable; when it times out
the native build fails with 'Download failed, halting portfile'.

Set X_VCPKG_ASSET_SOURCES to an x-script asset provider that redirects
GNU-FTP asset URLs to a reachable GNU mirror (mirrors.kernel.org, overridable
via NODE_LIBCURL_GNU_MIRROR) and falls back to the original URL for every
other asset. The value is appended to any X_VCPKG_ASSET_SOURCES the consumer
already set, so their asset cache keeps precedence. vcpkg still verifies each
asset's SHA512, so the mirror swap cannot substitute a different file.

The helper uses only native Node.js modules and is a no-op on non-Windows
(the source build only runs on Windows).
@aborovsky aborovsky self-assigned this Oct 6, 2026
github-actions Bot and others added 2 commits October 6, 2026 14:17
vcpkg launches the x-script asset command with CreateProcessW (no shell) in
its own build environment, where PATH is reset. A bare `node` program token
therefore isn't found and the download fails with 'CreateProcessW failed with
2', so vcpkg falls back to the unreachable GNU-FTP origin and times out.

Use process.execPath (the absolute path to the running Node) as the program
token instead of `node`, keeping both the interpreter and script paths
quoted for spaces.
@aborovsky

Copy link
Copy Markdown
Collaborator Author
  • Build and release CI job run must succeed

@aborovsky
aborovsky merged commit 2a18980 into develop Oct 6, 2026
37 checks passed
aborovsky added a commit to BrightSec/bright-cli that referenced this pull request Oct 6, 2026
@brightsec/node-libcurl 5.1.6 (BrightSec/node-libcurl#46) makes the Windows
vcpkg source build resilient to GNU FTP outages: it routes vcpkg asset
downloads through an x-script that falls back to a reachable GNU mirror
(gsasl etc.), fixing the download timeouts that broke the Windows e2e install.

Keeps bright-cli on the maintained node-libcurl release. The transitive build
deps (tar / brace-expansion / picomatch) were already patched on next via the
undici-override PR (#788); this bump moves the direct dependency itself and
carries the install-resilience fix.

Production webpack build and all 222 unit tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant