Skip to content

fix(eventsource): set use-URL-credentials flag#5489

Merged
KhafraDev merged 1 commit into
nodejs:mainfrom
Ram-blip:rework/eventsource-url-credentials
Jul 2, 2026
Merged

fix(eventsource): set use-URL-credentials flag#5489
KhafraDev merged 1 commit into
nodejs:mainfrom
Ram-blip:rework/eventsource-url-credentials

Conversation

@Ram-blip

@Ram-blip Ram-blip commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

This relates to...

Fixes EventSource potential-CORS request creation so it sets the correct use-URL-credentials flag.

Rationale

The HTML potential-CORS request algorithm requires the returned request’s use-URL-credentials flag to be set.

createPotentialCORSRequest() previously passed useCredentials, but Undici represents the use-URL-credentials flag using the separate useURLCredentials field. The Fetch authentication path reads useURLCredentials, so an EventSource URL containing credentials did not retry after a 401 authentication challenge.

Specification:
https://html.spec.whatwg.org/multipage/urls-and-fetching.html#create-a-potential-cors-request

Changes

Changed EventSource’s potential-CORS request creation to pass useURLCredentials: true instead of useCredentials: true.

Added a behavioral regression test that verifies:

  • the initial EventSource request does not send Authorization;
  • the server returns a Basic authentication challenge;
  • EventSource retries using credentials from the URL; and
  • the authenticated event stream is received.

Features

N/A

Bug Fixes

Fixes EventSource authentication with URL credentials after a 401 WWW-Authenticate Basic challenge.

Breaking Changes and Deprecations

N/A

Status

Signed-off-by: Ram-blip <ramcruze2000@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.45%. Comparing base (c4e045a) to head (e15bcba).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5489   +/-   ##
=======================================
  Coverage   93.45%   93.45%           
=======================================
  Files         110      110           
  Lines       37147    37147           
=======================================
  Hits        34716    34716           
  Misses       2431     2431           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KhafraDev KhafraDev merged commit 2dc7e18 into nodejs:main Jul 2, 2026
38 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 4, 2026
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.

3 participants