oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.85k stars 2.74k forks source link

FailedToOpenSocket downloading package manifest #6381

Open salman0ansari opened 1 year ago

salman0ansari commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 6.5.5-arch1-1 x86_64 unknown

What steps can reproduce the bug?

$ bunx create-next-app@latest

What is the expected behavior?

create next app

What do you see instead?

image

Additional information

No response

Electroid commented 1 year ago

Duplicate of #4988

silvio2402 commented 8 months ago

I'm getting this error when bun installing while being connected to my mobile hotspot:

bun i --verbose
[0.04ms] ".env.local"
bun install v1.0.26 (c75e768a)
Loaded 1645 hoisted_dependencies
Loaded 3185 resolutions
Loaded 3185 dependencies
Loaded 40 extern_strings
Loaded 115077 string_bytes
Enqueue package manifest for download: prisma-case-format
  🔍 Resolving [1/1] [PackageManager] waiting for 1 tasks
  🔍 prisma-case-format [6/6] 
error: FailedToOpenSocket downloading package manifest prisma-case-format
warn: warn: FailedToOpenSocket downloading package manifest prisma-case-format

warn: warn: FailedToOpenSocket downloading package manifest prisma-case-format

warn: warn: FailedToOpenSocket downloading package manifest prisma-case-format

warn: warn: FailedToOpenSocket downloading package manifest prisma-case-format

warn: warn: FailedToOpenSocket downloading package manifest prisma-case-format
error: prisma-case-format@^2.2.1 failed to resolve

Like in the other issue, I this this could be because of IPv6 since this issue only occurs when on mobile data. Note that I'm on a local dev container if that makes a difference.

Are there plans to fix support for IPv6 or is this just temporarily unsupported?

paperdave commented 7 months ago

the code path that FailedToOpenSocket should be revised to print the underlying system call error. not trivial on posix due to the error being deep within usockets.

ipv6 is a likely case. it is likely the getaddrinfo call, source shown:

    if (getaddrinfo(host, port_string, &hints, &result) != 0) {
        return LIBUS_SOCKET_ERROR;
    }

This api can be tested within Bun using Bun.dns.* functions, we have a flag to specifically use getaddrinfo as the backend. registry.npmjs.com is the domain for the registry.

Related: while doing work on bunx, i added some code to print a better error, but this only applies to Windows users.

                if (Environment.isWindows) {
                    try bun.windows.WSAGetLastError();
                } else {
                    // TODO(@paperdave): On POSIX, this will call getaddrinfo + socket
                    // the former of these does not set errno, and usockets does not have
                    // a way to propogate the error.
                    //
                    // This is caught in the wild: https://github.com/oven-sh/bun/issues/6381
                    // and we can definitely report a better here. It just is tricky.
                }
                return error.FailedToOpenSocket;