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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>27524</bug_id>
          
          <creation_ts>2014-12-05 11:02:24 +0000</creation_ts>
          <short_desc>Queue a fetch task on request&apos;s client rather than request?</short_desc>
          <delta_ts>2015-04-05 11:53:43 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>Fetch</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jungkee Song">jungkees</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bkelly</cc>
    
    <cc>jaffathecake</cc>
    
    <cc>mike</cc>
    
    <cc>nsm.nikhil</cc>
          
          <qa_contact>sideshowbarker+fetchspec</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>115969</commentid>
    <comment_count>0</comment_count>
    <who name="Jungkee Song">jungkees</who>
    <bug_when>2014-12-05 11:02:24 +0000</bug_when>
    <thetext>Currently, FetchEvent.default(http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#default-method) in Service Worker spec is invoking fetch with the request&apos;s synchronous flag set. But we&apos;d like to change it async so that it can run async as self.fetch() method does.

A problem lies in queuing a task for running the &quot;process response&quot; steps. Currently, fetch algorithm step 11 executes &quot;Queue a fetch task on *request* to process response for response.&quot; In this setting, the process response steps will run in the service worker client&apos;s responsible event loop instead of in the ServiceWorkerGlobalScope&apos;s responsible event loop.

Could you address this such that the process response steps can run in a client (environment settings object)&apos;s responsible event loop? Something like &quot;To queue a fetch task on request&apos;s client client to run an operation, queue a task to run an operation on client&apos;s responsible event loop using the networking task source.&quot; would be great.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115986</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-12-06 21:52:15 +0000</bug_when>
    <thetext>I don&apos;t understand. Client points to the service worker, no? Did you read the definition of queue a fetch task?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115997</commentid>
    <comment_count>2</comment_count>
    <who name="Jungkee Song">jungkees</who>
    <bug_when>2014-12-08 02:11:53 +0000</bug_when>
    <thetext>The request&apos;s client referred to within FetchEvent.default() is the service worker client not the service worker as the service worker client is the actual request initiator. So I was trying to see the possibility to set the target of the queue a fetch task explicitly a client rather than a request.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116008</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-12-08 12:51:20 +0000</bug_when>
    <thetext>If client is not the service worker, how does comment 0 make sense?

It&apos;s not entirely clear to me what kind of setup would work best here :-(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116035</commentid>
    <comment_count>4</comment_count>
    <who name="Jungkee Song">jungkees</who>
    <bug_when>2014-12-09 02:37:21 +0000</bug_when>
    <thetext>(In reply to Anne from comment #3)
&gt; If client is not the service worker, how does comment 0 make sense?
&gt; 

Yeah, right. If we wanted this, it should be defined as &quot;To queue a fetch task on environment settings object _client_ to run an operation, queue a task to run an operation on _client_&apos;s responsible event loop using the networking task source.&quot; and I would have to run &quot;To queue a fetch task on the service worker(https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#dfn-service-worker-global-scope-service-worker)&apos;s environment settings object to run an operation, do the steps.&quot; in e.default() algorithm.

&gt; It&apos;s not entirely clear to me what kind of setup would work best here :-(

If it doesn&apos;t make any side effects, overriding the request&apos;s client to service worker&apos;s environment settings object in e.default() can be an option as well. But I&apos;m a bit worried about this lest it break any forward compatibility with fetch algorithm.

What say you?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117344</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-01-20 10:01:46 +0000</bug_when>
    <thetext>Say we have a worker A that is controlled by a service worker SW.

A invokes fetch() which creates a &quot;fetch&quot; which ends up in SW. If SW then does fetchEvent.default() and that reuses &quot;fetch&quot; from A, how are both parties (A and SW) getting the correct annotated event loop tasks?

That seems impossible with the current setup.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117542</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-01-28 11:35:28 +0000</bug_when>
    <thetext>So the answer here is to remove default() and mark this WONTFIX, no?

See https://github.com/slightlyoff/ServiceWorker/issues/607 about replacing default().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117550</commentid>
    <comment_count>7</comment_count>
    <who name="Jungkee Song">jungkees</who>
    <bug_when>2015-01-28 11:59:30 +0000</bug_when>
    <thetext>It depends on the conclusion we&apos;ll end up. I thought you were opened to find a way to preserve the original (A&apos;s) request&apos;s setup including request&apos;s client (as A&apos;s environment settings object) and referrer to keep default(). However, I think e.default() doesn&apos;t provide any advantages over fetch(e.request) to authors having considered that Fetch provides Response.finalURL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119237</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-04-05 11:53:43 +0000</bug_when>
    <thetext>Yeah, Referer preservation is lost though perhaps we can make Referer settable and save it. We&apos;ll see. I don&apos;t think anyone wants default() back at this point though and the proposed model in comment 0 is still broken.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>