Skip to content

opencode.ai resolves to four IPv6 addresses and stalls Bun fetch on IPv6 blackhole networks #36808

Closed

Description

@heimoshuiyu

Description

Over the past two days, multiple OpenCode users in China have reported that opencode-go becomes stuck indefinitely on networks with broken or blackholed IPv6. Other applications, including browsers accessing https://opencode.ai, quickly fall back to IPv4 and work normally.

opencode.ai returns exactly four AAAA records, while Bun/uSockets uses four concurrent connection slots. My hypothesis is that the four unreachable IPv6 addresses occupy every slot and block IPv4 fallback.

I reproduced this on dual-stack AWS by dropping TCP/443 only for the four IPv6 addresses while keeping IPv4 healthy. Bun 1.3.14 took 132 seconds to fall back to IPv4, and OpenCode v1.17.20 took approximately 133 seconds to receive an HTTP response. The test used the same OpenCode Go endpoint with dummy credentials because the delay occurs before authentication.

Could the number of AAAA records returned by opencode.ai be reduced from four to two as an immediate mitigation?

Related reports: #36029 and #35035. Related Bun issue: oven-sh/bun#33278

Plugins

None

OpenCode version

1.17.20 & v2 latest commit

Steps to reproduce

  1. Use a dual-stack machine with working public IPv4 and IPv6.

  2. Confirm that opencode.ai returns four A and four AAAA records:

    dig @1.1.1.1 opencode.ai A +short
    dig @1.1.1.1 opencode.ai AAAA +short
  3. Silently drop TCP/443 traffic to the four IPv6 addresses while leaving IPv4 working:

    sudo nft add table inet opencode_repro
    sudo nft 'add chain inet opencode_repro output { type filter hook output priority -100; policy accept; }'
    sudo nft 'add rule inet opencode_repro output ip6 daddr { 2606:4700:78::90:0:140, 2606:4700:78::90:0:141, 2606:4700:78::90:0:142, 2606:4700:78::90:0:143 } tcp dport 443 counter drop'
  4. Verify that IPv4 works while IPv6 times out:

    curl -4 --connect-timeout 5 https://opencode.ai/
    curl -6 --connect-timeout 5 https://opencode.ai/
  5. Run OpenCode Go using an account with opencode-go configured:

    time opencode run --model opencode-go/deepseek-v4-flash "Reply with hi"
  6. The request should stall while the four IPv6 connections are blackholed. Compare with IPv6 disabled for the process:

    time BUN_FEATURE_FLAG_DISABLE_IPV6=1 opencode run --model opencode-go/deepseek-v4-flash "Reply with hi"

Screenshot and/or share link

N/A. Reproduced with the commands above.

Operating System

Amazon Linux 2023, kernel 6.1.176-221.360.amzn2023.x86_64

Terminal

Not relevant; reproduced with non-interactive opencode run

Activity

  1. github-actions commented on Jul 14, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    You've already referenced these in your report, which is great. Consider whether this issue adds new information (e.g., the hypothesis about four AAAA records filling all four connection slots, the AWS reproduction, and the mitigation request to reduce AAAA records) or if it should be consolidated into one of the existing issues.

  2. heimoshuiyu commented on Jul 14, 2026

    @heimoshuiyu
    ContributorAuthor

    One clarification: the information about Bun/uSockets having four concurrent connection slots came from source-code analysis performed by my coding agent. I am not familiar enough with Bun internals to independently confirm that this interpretation is completely correct.

    However, I have now confirmed the observable behavior with a hostname that returns two A and two AAAA records. miku.social resolved in this order with Bun 1.3.14:

    2 IPv6 addresses
    2 IPv4 addresses
    

    I silently dropped TCP/443 traffic to both IPv6 addresses while keeping IPv4 healthy. Direct IPv6 timed out, direct IPv4 returned HTTP 200 in 1.145 seconds, and Bun fetch("https://miku.social/") returned HTTP 200 in 1.241 seconds.

    In contrast, with all four opencode.ai IPv6 addresses blackholed, Bun took approximately 132 seconds before falling back to IPv4. This supports the hypothesis that reducing the opencode.ai AAAA response from four addresses to two would provide an effective immediate mitigation.

  3. yao8762 commented on Aug 6, 2026

    @yao8762

    Hi, we hit exactly the same root cause and found a reliable workaround.

    Environment: Taiwan academic network (TANet) — IPv6 is half-broken; Router Advertisement periodically announces a default IPv6 route that silently blackholes packets (packets are dropped, not rejected).

    Symptom: Python-based clients (OpenAI SDK/urllib, RFC 6724 IPv6-first) connect to opencode.ai over IPv6 → TCP SYN retries until ~125s timeout. curl/browsers are fine (Happy Eyeballs / IPv4-first). In our case the blackhole IPv6 route only appears intermittently (RA lifecycle), so the issue came and went — very confusing until we correlated it with ip -6 route show default.

    Workaround (client-side, permanent) — pin opencode.ai to IPv4 in /etc/hosts:

    172.65.90.20 opencode.ai
    172.65.90.21 opencode.ai
    172.65.90.22 opencode.ai
    172.65.90.23 opencode.ai
    104.20.32.17 api.opencode.ai
    172.66.173.149 api.opencode.ai
    

    After pinning: 100K-token context calls went from ~125s to ~5-8s.

    Root cause is upstream DNS returning AAAA records on broken-IPv6 networks — a Happy Eyeballs (RFC 8305) fix in the client would solve it for everyone, but the hosts pin works today.

  4. hylonGG commented on Aug 15, 2026

    @hylonGG

    奇怪的是之前的老版本一致用的正常,升级后就无法使用了,我也排查了好久,才发现是移动网络IPV6问题。

  5. heimoshuiyu commented on Sep 4, 2026

    @heimoshuiyu
    ContributorAuthor

    this was fix in bun v1.4.0

  6. russrapper15-png commented on Sep 4, 2026

    @russrapper15-png

    this was fix in bun v1.4.0

    Certainly! Here is the bio information from the profile you shared:

           Official Website
    

    Kevin Costner at AllMusic
    Yes, this is the really me.
    LIVE Pro

    FLEM Live Creator
    The real profile
    Kelvin Michael Costner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions