Fetch fails to detect broken IPv6
If apk is running in a dual stack environment where AAAA records are returned but IPv6 packets do not go through fetch will try to connect only to the v6 addresses and will take a very long time to fail and fall back to v4. In my case, this is with building docker images.
Other utilities such as curl
work correctly in the same situation because they use the Happy Eyeballs algorithm (RFC 8305).
apk:
~ # apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
...(hangs until timeout)
curl:
~ # curl -vI https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
* Trying 2a04:4e42:600::645:443...
* Trying 151.101.194.133:443...
* Connected to dl-cdn.alpinelinux.org (151.101.194.133) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
...CLIPPED
curl IPv6 only:
~ # curl -6 -vI https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
* Trying 2a04:4e42::645:443...
...(hangs until timeout)