Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP related regression in v1.1.27 #14184

Closed
Mudbill opened this issue Sep 26, 2024 · 8 comments · Fixed by #15160
Closed

HTTP related regression in v1.1.27 #14184

Mudbill opened this issue Sep 26, 2024 · 8 comments · Fixed by #15160
Assignees
Labels
bug Something isn't working node:http regression

Comments

@Mudbill
Copy link

Mudbill commented Sep 26, 2024

What version of Bun is running?

1.1.29+6d43b3662

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

I noticed a strange issue while using the contentful package after upgrading Bun. After some testing, I discovered the issue only occurs on Bun versions after 1.1.26 (last working version).

The issue is that the Contentful API client seemingly attempts to connect to their API URL using a combination of https:// and port 80. This causes the connection to fail.

I originally reported this in the Contentful Discord server before I found the relation to Bun. Therefore, I suspect this may be a Node-compatibility related issue.

Contentful uses Axios under the hood for communication.

I haven't yet found the exact piece of code causing this, but I would assume it has something to do with the detection of which protocol to use and how to match up port 80 or 443 to that protocol. I will pop back with anything I find, but maybe someone more familiar with the related changes in v1.1.27 already has an inkling? 😅

Reproduction

While using an affected Bun version (such as latest, v1.1.29 atm), create a new project and bun add contentful

In the index.ts file, add the following:

import { createClient } from "contentful";

const client = createClient({
  space: "example",
  accessToken: "nothing",
  retryLimit: 1, // just to skip retries for 30 seconds
});

await client.getEntries();

Run bun . on the file. The output will look something like this:

% bun .
[warning] Connection error occurred. Waiting for 2035 ms before retrying...
ConnectionRefused: Unable to connect. Is the computer able to access the url?

ConnectionRefused: Unable to connect. Is the computer able to access the url?
 path: "https://cdn.contentful.com:80/spaces/example/environments/master/entries"

Bun v1.1.29 (macOS arm64)

What is the expected behavior?

I expect the API client to connect as intended, and as it did previously in version 1.1.26 or prior. The protocol should be https:// and the port should be 443.

What do you see instead?

The API client seemingly attempts to connect to their API URL using a combination of https:// and port 80. This causes the connection to fail.

Additional information

I tested several versions of Contenful's package. Both older and newer versions worked before the Bun upgrade, and both stopped working after.

This also likely has nothing to do with OS, as it also occurs on Linux/ARM (although I suppose I haven't tried an x86 OS)

@Jarred-Sumner
Copy link
Collaborator

@nektro this is probably a regression from the node:http agent changes

@inmativ
Copy link

inmativ commented Oct 31, 2024

This problem already existed in previous versions.
#6443

@mouthzipper
Copy link

any workaround on this issue? i'm currently stuck at v1.1.26

@quangpao
Copy link

quangpao commented Nov 4, 2024

Facing the same issue in v1.1.34

@waken22
Copy link

waken22 commented Nov 14, 2024

Any updates on the issue, or at least a workaround?

@waken22
Copy link

waken22 commented Nov 15, 2024

Hi! Thank you for your time, i updated bun to canary release and seems like the issue is still there, probably not related to what it was fixed.

 waken@Andromeda  ~/eom-webpage   master ±  bun upgrade --canary
Congrats! You're already on the latest canary build of Bun

To downgrade to the latest stable release, run bun upgrade --stable

Trying the astro setup + contentful SDK fails to connect internally to their API:

✘ waken@Andromeda  ~/eom-webpage   master ±  bun run dev --host
$ bunx --bun astro dev --host
13:13:20 [types] Generated 1ms
13:13:20 [vite] Re-optimizing dependencies because lockfile has changed

astro  v4.16.13 ready in 1165 ms

┃ Local    http://localhost:4321/
┃ Network  http://172.30.234.62:4321/

13:13:20 watching for file changes...
[warning] Connection error occurred. Waiting for 2106 ms before retrying...
[warning] Connection error occurred. Waiting for 2076 ms before retrying...
[warning] Connection error occurred. Waiting for 2650 ms before retrying...
[warning] Connection error occurred. Waiting for 2671 ms before retrying...
[warning] Connection error occurred. Waiting for 3445 ms before **retrying...**

Meanwhile, using npx seems to work fine without any issue:

 ✘ waken@Andromeda  ~/eom-webpage   master ±  npx astro dev --host
13:11:57 [types] Generated 1ms

 astro  v4.16.13 ready in 304 ms

┃ Local    http://localhost:4321/
┃ Network  http://172.30.234.62:4321/

13:11:57 watching for file changes...
13:11:59 [200] / 17ms
{ sys: { type: 'Array' }, total: 0, skip: 0, limit: 100, items: [] }
13:12:13 [200] /patchnotes 208ms

@waken22
Copy link

waken22 commented Nov 15, 2024

Sorry to ping @cirospaciari just in case it doesn't get notified

@nektro
Copy link
Member

nektro commented Nov 15, 2024

lets open a new issue for that, since the repro given in the original issue now behaves the same in bun as it does in node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node:http regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants