Skip to content

fetch(Request, init) drops RequestInit overrides in interception #4

Description

@mktbsh

Summary

createFetchRequest clones the incoming Request when fetch is called with an existing Request object, but it ignores the second init argument.

As a result, intercepted metadata can differ from the actual request that was sent.

Current behavior

For a call like this:

const base = new Request("https://example.com/base", { method: "GET" });
await fetch(base, { method: "POST", body: "payload" });

the interceptor sees the original GET request instead of the effective POST request.

Expected behavior

The intercepted Request should reflect the same effective request that fetch sends after applying init overrides.

Impact

  • matcher can evaluate against the wrong method, headers, or body
  • onIntercept can observe stale request data
  • Consumers cannot rely on the intercepted Request as a faithful representation of network traffic

Suggested acceptance criteria

  • createFetchRequest preserves the effective request semantics for fetch(Request, init)
  • Unit tests cover method/body/header overrides when a Request and init are both provided

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions