<?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>277588</bug_id>
          
          <creation_ts>2024-08-03 03:11:05 -0700</creation_ts>
          <short_desc>iOS Web Extension service worker fails to load unless I delay all JS via setTimeout</short_desc>
          <delta_ts>2025-05-16 16:42:32 -0700</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 17</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 17</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>274331</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="@fregante">bugs</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>timothy</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2050477</commentid>
    <comment_count>0</comment_count>
    <who name="@fregante">bugs</who>
    <bug_when>2024-08-03 03:11:05 -0700</bug_when>
    <thetext>In the latest version of Refined GitHub on the App Store, currently v24.7.10, the service worker fails to load: https://apps.apple.com/us/app/refined-github/id1519867270

- This only happens on iOS, including the simulator
- There are no syntax errors or uncaught errors in the code
- The same file works when loaded via `background.scripts` instead of `background.service_worker`
- It&apos;s impossible to debug because the &quot;Service worker&quot; does not appear in Safari&apos;s Develop -&gt; MyDevice list
- It seems to occasionally run on my iPhone, e.g. it responds to action.onClicked, but rarely, and it never responds to runtime.sendMessage.

Most importantly:

- The same file works if I wrap the entire background.js contents in `setTimeout(() =&gt; {/*contents*/}, 1000)`

Versions:

- iOS 17.5 and 17.6 iPhone 15 Pro Max Simulator

Questions:

- If you&apos;d like me to attach a repro, would .xcarchive be enough?
- How can I debug service worker failures on iOS? It seems impossible because &quot;Automatically Show Web Inspector for JSContexts&quot; does not work for other devices

Repro:

- GitHub repo with the extension: https://github.com/refined-github/refined-github/tree/24.7.10
- It needs Node 21+, `npm install &amp;&amp; npm run build`. The Xcode project is in /safari

References:

- https://github.com/refined-github/refined-github/issues/7590
- https://github.com/refined-github/refined-github/issues/7629

Workarounds:

- I&apos;ll have to ship `background.scripts` until this is resolved</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2051871</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-08-10 03:12:27 -0700</bug_when>
    <thetext>&lt;rdar://problem/133593437&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2055151</commentid>
    <comment_count>2</comment_count>
    <who name="@fregante">bugs</who>
    <bug_when>2024-08-24 13:17:51 -0700</bug_when>
    <thetext>Some updates:

- It has been working recently, maybe thanks to iOS 17.6.1. I have not checked the Simulator though
- Version 24.8.20 has been released on the App Store and it was reverted to a background script anyway

If you need a build of the service worker version let me know. 

Overall I wish there was *any* way to debug these issues. I don&apos;t know if the service worker can be debugged at all in extensions, if it fails on launch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2117805</commentid>
    <comment_count>3</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2025-05-16 16:41:45 -0700</bug_when>
    <thetext>This was actually resolved in:
&lt;rdar://126825362&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2117806</commentid>
    <comment_count>4</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2025-05-16 16:42:32 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 274331 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>