Skip to content

Refactor options handling for fetch request#6422

Open
dalechyn wants to merge 1 commit intoopen-telemetry:mainfrom
dalechyn:patch-1
Open

Refactor options handling for fetch request#6422
dalechyn wants to merge 1 commit intoopen-telemetry:mainfrom
dalechyn:patch-1

Conversation

@dalechyn
Copy link

Which problem is this PR solving?

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #6421

Short description of the changes

Doesn't discard RequestInit now.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Patched internally in my project and worked since.

  • Test A

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@dalechyn dalechyn requested review from a team as code owners February 18, 2026 22:04
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 18, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: dalechyn / name: Vladyslav Dalechyn (ddac73e)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request attempts to fix issue #6421 where RequestInit options were being discarded when a Request object was passed as the first argument to fetch() along with additional options in the second argument.

Changes:

  • Modified the options handling logic to merge Request and RequestInit when both are provided
  • Changed the options construction for non-Request inputs to include the URL

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +423 to +425
const options = args[0] instanceof Request
? new Request(args[0], args[1])
: { url: args[0], ...args[1] };
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

There are no tests covering the scenario where both a Request object and a RequestInit object are passed to fetch (e.g., fetch(new Request(...), requestInit)). This is the exact issue mentioned in #6421. Tests should be added to verify that the RequestInit options properly override or extend the Request object's properties, as per the Fetch API specification.

Suggested change
const options = args[0] instanceof Request
? new Request(args[0], args[1])
: { url: args[0], ...args[1] };
const options =
args[0] instanceof Request
? new Request(args[0], args[1])
: new Request(args[0] as RequestInfo, args[1]);

Copilot uses AI. Check for mistakes.
const options = args[0] instanceof Request ? args[0] : args[1] || {};
const options = args[0] instanceof Request
? new Request(args[0], args[1])
: { url: args[0], ...args[1] };
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The url property should not be added to the options object when args[0] is not a Request instance. The RequestInit interface doesn't include a url property, and adding it could cause issues when the options object is passed to user hooks or the original fetch API. The line should be args[1] || {} instead of { url: args[0], ...args[1] }.

Suggested change
: { url: args[0], ...args[1] };
: (args[1] || {});

Copilot uses AI. Check for mistakes.
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.

Bug: RequestInit options lost when Request object passed as first argument to fetch()

1 participant

Comments