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

Fix default ports being rejected in preconnect #16953

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

heimskr
Copy link
Member

@heimskr heimskr commented Feb 1, 2025

What does this PR do?

Fixes an issue where port validation throws an error after default ports get normalized out of URLs passed to fetch.preconnect.

  • Documentation or TypeScript types
  • Code changes

How did you verify your code works?

I ran this code:

import { fetch } from "bun";
fetch.preconnect("https://example.com");

Fails in the current release version but doesn't with this PR.

@robobun
Copy link

robobun commented Feb 1, 2025

Updated 7:37 PM PT - Jan 31st, 2025

@heimskr, your commit 2bc637c has 2 failures in Build #10948:


🧪   try this PR locally:

bunx bun-pr 16953

@heimskr heimskr requested review from a team and dylan-conway and removed request for a team February 1, 2025 02:34
@heimskr
Copy link
Member Author

heimskr commented Feb 1, 2025

Now it fails to reject port 0. I'll fix this.

@dylan-conway
Copy link
Member

I don't fully understand this change yet, but similar might be needed in bun_js.zig in doPreconnect

@heimskr
Copy link
Member Author

heimskr commented Feb 1, 2025

I don't fully understand this change yet, but similar might be needed in bun_js.zig in doPreconnect

My latest commit moves the check into hasValidPort, which is used in both doPreconnect and Bun__fetchPreconnect_.

Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test

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.

4 participants