这是indexloc提供的服务,不要输入任何密码
Skip to content

Bug: PATCH Request Body Ignored/Stripped When Using fetch API on React 19.2.0 #35150

@cboychinedu

Description

@cboychinedu

When attempting to send a JSON request body using the standard fetch API with the HTTP method set to PATCH, the body is consistently ignored or stripped from the request payload. This regression makes it impossible to perform partial updates requiring data transfer via the request body on React projects running version 19.2.0.

The issue is specifically observed when correctly setting the Content-Type: application/json header and stringifying the payload using JSON.stringify().

To Reproduce

  1. Set up a new React project using version 19.2.0
  2. Create a component that performs a PATCH request using the fetch API, similar to the code snippet provided below.
  3. Set a network monitor (e.g., Chrome Devtools, Wireshark) on the target endpoint.
  4. Execute the handlePatch function.

Minimal Code Snippet:

// This is the structure used to reproduce the bug
const dataToUpdate = { status: 'pending', notes: 'Needs review' };

fetch('[https://api.example.com/items/123](https://api.example.com/items/123)', {
    method: 'PATCH',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify(dataToUpdate),
})
.then(response => response.json())
.then(data => console.log('Response:', data));
// When monitoring the request, the body is empty or not transmitted.

Expected Behavior

The PATCH request should include the serialized JSON object ({"status":"pending", "notes":"Needs review"}) in its body, as specified by the body property of the fetch configuration object.

Observed Behavior

The request is sent with an empty body, or the server-side logging indicates a null/empty body was received, despite the client-side fetch configuration containing a valid JSON.stringify(body).

Environment

  • React Version: 19.2.0
  • Browser: All (Confirmed on macOS, Windows 11)
  • Operating System: All (Confirmed on macOS, Windows 11)
  • Environment Type: Standard web browser environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions