Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@ export class FetchInstrumentation extends InstrumentationBase<FetchInstrumentati
args[0] instanceof Request ? args[0].url : String(args[0])
).href;

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] };
Comment on lines +423 to +425
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.
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.
const createdSpan = plugin._createSpan(url, options);
if (!createdSpan) {
return original.apply(this, args);
Expand Down