<html>
    <head>
      <base href="https://bugs.webkit.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - XHR with requestType document broken for larger HTML files"
   href="https://bugs.webkit.org/show_bug.cgi?id=231138">231138</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>XHR with requestType document broken for larger HTML files
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>Safari 15
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Critical
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DOM
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned@lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>erik.witt@baqend.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When requesting HTML documents via XHRHttpRequests the response object is missing even when the request itself was successful.

Ways to reproduce:

1. Go to <a href="https://www.decathlon.de">https://www.decathlon.de</a>
2. In the console execute this code
```
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.open('GET', '<a href="https://www.decathlon.de/browse/c0-alle-sportarten-a-z/c1-fahrrad-welt/c3-mountainbike/_/N-obq78x">https://www.decathlon.de/browse/c0-alle-sportarten-a-z/c1-fahrrad-welt/c3-mountainbike/_/N-obq78x</a>', true); 
xhr.responseType = 'document';

xhr.addEventListener('readystatechange', () => {
  if (xhr.readyState === 4) {
    console.log('Success')
    console.log('Res: ' + xhr.response)
  }
});

// Handle errors of XHR connection
xhr.addEventListener('error', (e) => {

    console.log('Error', e)
});
xhr.send();
```

3. Observe that the xhr.response is null even though the request was successful.


The same issue is reproducable on a lot of domains but does not happen for all HTML files. It seems to be related to the size of the HTML document though. For example, if you swap the URL in the example above for this one <a href="https://www.decathlon.de/p/mountainbike-e-st-520-27-5-zoll-grau-gelb/_/R-p-311400">https://www.decathlon.de/p/mountainbike-e-st-520-27-5-zoll-grau-gelb/_/R-p-311400</a> everything works fine and the response is available.

This issue is highly critical for a lot of our customers. Is there a workaround to still use XHR for those files until there is a fix for the issue?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>