<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>284184</bug_id>
          
          <creation_ts>2024-12-06 12:35:26 -0800</creation_ts>
          <short_desc>Checking for presence of request body in Service Worker causes body to be dropped from request</short_desc>
          <delta_ts>2025-01-07 01:04:20 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Service Workers</component>
          <version>Safari 18</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/49923</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Wes">wes</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>annevk</cc>
    
    <cc>cdumez</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2079710</commentid>
    <comment_count>0</comment_count>
    <who name="Wes">wes</who>
    <bug_when>2024-12-06 12:35:26 -0800</bug_when>
    <thetext>If a service worker intercepts a fetch request and checks for the presence of a body then the body will get dropped from the SW&apos;s fetch request.

NOTE: I have tried this with both &quot;Content-Type: application/json&quot; and &quot;Content-Type: x-www-form-urlencoded&quot; and both hit this bug.


&gt; // sw code
&gt; self.addEventListener(&quot;fetch&quot;, (event) =&gt; {
&gt;  event.respondWith(
&gt;    (async () =&gt; {
&gt;      if (event.request.body) {
&gt;        console.log(&quot;this request has a body&quot;);
&gt;      }
&gt;      return fetch(event.request);
&gt;    })()
&gt;  );
&gt;});

I have made a repro at https://github.com/wes-goulet/webkit-service-worker-drop-body-repro

This same check of a request body causes no issue if it happens on the main thread (not in SW).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2081593</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-12-13 12:36:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/141454387&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2085073</commentid>
    <comment_count>2</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2025-01-06 09:17:14 -0800</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/49923</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2085349</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-01-07 01:04:17 -0800</bug_when>
    <thetext>Committed 288514@main (6c800745251d): &lt;https://commits.webkit.org/288514@main&gt;

Reviewed commits have been landed. Closing PR #38561 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>