<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohamed Gado</title>
    <description>The latest articles on DEV Community by Mohamed Gado (@mohamedgado).</description>
    <link>https://dev.to/mohamedgado</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4238010%2F81bfb3a3-d85e-4209-a232-f5f2ebe47acf.png</url>
      <title>DEV Community: Mohamed Gado</title>
      <link>https://dev.to/mohamedgado</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohamedgado"/>
    <language>en</language>
    <item>
      <title>Arabic paragraphs in Markdown render left to right: a rehype plugin fix</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Sun, 29 Nov 2026 08:13:38 +0000</pubDate>
      <link>https://dev.to/mohamedgado/arabic-paragraphs-in-markdown-render-left-to-right-a-rehype-plugin-fix-2hco</link>
      <guid>https://dev.to/mohamedgado/arabic-paragraphs-in-markdown-render-left-to-right-a-rehype-plugin-fix-2hco</guid>
      <description>&lt;p&gt;Markdown has no syntax for text direction, so an Arabic paragraph inside an English page inherits &lt;code&gt;dir="ltr"&lt;/code&gt; unless the renderer adds a direction. On my site I fixed it with a small rehype plugin that sets &lt;code&gt;dir="rtl"&lt;/code&gt; when a block starts in Arabic and has more Arabic letters than Latin ones. Checking only one of those two conditions gets some paragraphs wrong.&lt;/p&gt;

&lt;p&gt;My app pages are written in English and carry lists of Arabic links. Each Arabic run already had &lt;code&gt;lang="ar"&lt;/code&gt;, so a screen reader picked the right voice. Direction is a separate attribute, and nothing set it. The words themselves were shaped correctly, but the block was left-aligned and its separators and final full stop sat at the wrong end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not dir="auto"?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;dir="auto"&lt;/code&gt; takes the direction of the first strongly directional character. That works for a comment field, where each block is in one language. In mixed prose it flips an English paragraph that happens to open with an Arabic name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not count letters?
&lt;/h2&gt;

&lt;p&gt;Counting was my first attempt: more Arabic letters than Latin means right to left. An existing test failed on this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Masareef (مصاريف) is an app. [تحميل مصاريف بالعربي](/x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is an English sentence followed by a long Arabic link. The Arabic letters win the count, and the English sentence flips. Requiring the first letter to be Arabic as well fixes it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The plugin
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;rehypeArabicBlocks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HastRoot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;visit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'element'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Element&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!/^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tagName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
      &lt;span class="nf"&gt;visit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'text'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;arabic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nc"&gt;Script&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Arabic&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;gu&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;latin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nc"&gt;Script&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Latin&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;gu&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;L&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arabic&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;latin&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!/&lt;/span&gt;\&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nc"&gt;Script&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Arabic&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;
      &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;dir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'rtl'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'text-align:right'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It runs after &lt;code&gt;remark-rehype&lt;/code&gt;, so it sees the final HTML elements. &lt;code&gt;\p{Script=...}&lt;/code&gt; needs the &lt;code&gt;u&lt;/code&gt; flag.&lt;/p&gt;

&lt;h2&gt;
  
  
  The test
&lt;/h2&gt;

&lt;p&gt;Keep both cases in one test, so a later change can't fix one and break the other:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;renderMarkdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'بالعربية: [محفظة الذهب](/x)\n\nHadeed (حديد) is a workout planner.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;/&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="n"&gt;dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"rtl"&lt;/span&gt; &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"text-align:right"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="n"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ar"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;بالعربية&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;/&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nc"&gt;Hadeed&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule has a limit: a Latin-heavy block that opens in Arabic stays left to right. If your content has those, set the direction by hand.&lt;/p&gt;

</description>
      <category>markdown</category>
      <category>rtl</category>
      <category>webdev</category>
    </item>
    <item>
      <title>AbortError: signal is aborted without reason, and why my error tracker saw it</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Sat, 28 Nov 2026 17:11:38 +0000</pubDate>
      <link>https://dev.to/mohamedgado/aborterror-signal-is-aborted-without-reason-and-why-my-error-tracker-saw-it-4g67</link>
      <guid>https://dev.to/mohamedgado/aborterror-signal-is-aborted-without-reason-and-why-my-error-tracker-saw-it-4g67</guid>
      <description>&lt;p&gt;&lt;code&gt;AbortError: signal is aborted without reason&lt;/code&gt; is the message Chrome and Edge give the error an &lt;code&gt;AbortController&lt;/code&gt; creates when you call &lt;code&gt;controller.abort()&lt;/code&gt; with no argument. Firefox and Safari give the same error a different text: &lt;code&gt;The operation was aborted.&lt;/code&gt; On my &lt;a href="https://www.mohamedgado.com/projects/social-media-downloader" rel="noopener noreferrer"&gt;Social Downloader&lt;/a&gt; it came from a timeout of my own, which my code caught. It still reached error tracking as unhandled, because a second promise chained off the same &lt;code&gt;fetch&lt;/code&gt; had no catch. Passing &lt;code&gt;abort()&lt;/code&gt; a reason, and filtering on the error's name rather than its text, fixes both halves.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does "signal is aborted without reason" mean?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;abort()&lt;/code&gt; takes an optional reason. When you leave it out, the signal makes one for you: a &lt;code&gt;DOMException&lt;/code&gt; named &lt;code&gt;AbortError&lt;/code&gt;. Every &lt;code&gt;fetch&lt;/code&gt; using that signal rejects with that exception.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AbortController&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;// "AbortError"&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Chrome: "signal is aborted without reason"&lt;/span&gt;
                                              &lt;span class="c1"&gt;// Firefox, Safari: "The operation was aborted."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The message means code in the page cancelled the request and gave no explanation. A network failure or a server refusal looks different (see the FAQ below).&lt;/p&gt;

&lt;h2&gt;
  
  
  Where mine came from: a timeout with no reason
&lt;/h2&gt;

&lt;p&gt;The downloader resolves a TikTok link two ways at once. The browser asks a public API directly, and the server resolves the same link in parallel. Whichever answers first wins. The browser call has a 6 second budget, written like this (trimmed to its shape):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;resolveInBrowser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AbortController&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;timer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="c1"&gt;// timeout, offline, blocked: let the server answer&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;fetch&lt;/code&gt; and the &lt;code&gt;.json()&lt;/code&gt; both sit inside the &lt;code&gt;try&lt;/code&gt;, and the &lt;code&gt;catch&lt;/code&gt; turns a timeout into &lt;code&gt;null&lt;/code&gt;. On 27 November a visitor on Edge pasted a link to a TikTok photo post. The browser call ran out its 6 seconds, the server answered that it could not resolve the post, and the app showed that message, as designed. Four milliseconds later the error tracker recorded &lt;code&gt;AbortError: signal is aborted without reason&lt;/code&gt;, marked as unhandled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a caught AbortError can still show as unhandled
&lt;/h2&gt;

&lt;p&gt;The event had one stack frame, in one of my own bundles. I fetched that bundle from production and read the code at the frame's column. It was the &lt;code&gt;controller.abort()&lt;/code&gt; inside the timer, which says less than it seems to. A &lt;code&gt;DOMException&lt;/code&gt; records its stack when it is created, and &lt;code&gt;abort()&lt;/code&gt; creates it. So the frame shows who cancelled the request, not who failed to handle the rejection. Every promise that rejects with this exception carries the same stack, wherever it was left unhandled.&lt;/p&gt;

&lt;p&gt;My promise was handled, so the unhandled one had to be someone else's. Any script that patches &lt;code&gt;window.fetch&lt;/code&gt; to watch requests can make a second promise from the original:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;originalFetch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;fetch&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;fetch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;originalFetch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;record&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// a second promise, never caught&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The page gets &lt;code&gt;request&lt;/code&gt; back and catches it. The &lt;code&gt;.then()&lt;/code&gt; the wrapper made is a separate promise, and it rejects with the same &lt;code&gt;AbortError&lt;/code&gt;. Nothing catches that one, so the browser fires &lt;code&gt;unhandledrejection&lt;/code&gt;, and an error tracker listening for it reports the cancel as a crash. Browser extensions, analytics snippets and ad scripts all patch &lt;code&gt;fetch&lt;/code&gt; this way. The stack does not say which one it was, and I could not find out. I could check that every path in my code caught it, and it did.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to tell if the error is yours
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Check how it was captured. An error tracker that marks it &lt;code&gt;handled: false&lt;/code&gt; caught it from &lt;code&gt;unhandledrejection&lt;/code&gt; or &lt;code&gt;window.onerror&lt;/code&gt;, not from your own &lt;code&gt;catch&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Map the frame to code. Fetch the production bundle and read the code at the frame's line and column. If Cloudflare or a bot filter sits in front of the site, send a browser &lt;code&gt;User-Agent&lt;/code&gt;, or you will get a challenge page instead of JavaScript.&lt;/li&gt;
&lt;li&gt;If the frame is an &lt;code&gt;abort()&lt;/code&gt; call, read every promise that uses that signal. When each one is awaited inside a &lt;code&gt;try&lt;/code&gt;, or has a &lt;code&gt;.catch()&lt;/code&gt;, the unhandled copy is not yours.&lt;/li&gt;
&lt;li&gt;Read the session around it. Mine showed &lt;code&gt;resolve_failed&lt;/code&gt; 4 ms before the exception: the cancel was the timeout doing its job.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to fix it
&lt;/h2&gt;

&lt;p&gt;Give &lt;code&gt;abort()&lt;/code&gt; a reason, and the rejection says what happened in every browser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DOMException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'tikwm timed out'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'TimeoutError'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// or let the platform do it:&lt;/span&gt;
&lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// rejects with a TimeoutError&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you switch to &lt;code&gt;TimeoutError&lt;/code&gt;, check every &lt;code&gt;catch&lt;/code&gt; that tests &lt;code&gt;error.name === 'AbortError'&lt;/code&gt;. A timeout no longer matches it, so code that treats a cancel as "the user changed their mind" will now treat a timeout as a failure. That is usually what you want, but check it on purpose.&lt;/p&gt;

&lt;p&gt;For the error tracker, filter on the name, or on every engine's text. My error filter already dropped this cancel, but only in Safari's wording, &lt;code&gt;The operation was aborted.&lt;/code&gt; Chrome's wording went straight through. A pattern for one engine's message misses the others, so match them together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;BARE_ABORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;DOMException&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="nc"&gt;AbortError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;The&lt;/span&gt; &lt;span class="n"&gt;operation&lt;/span&gt; &lt;span class="n"&gt;was&lt;/span&gt; &lt;span class="n"&gt;aborted&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;aborted&lt;/span&gt; &lt;span class="n"&gt;without&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your tracker gives you the exception type as a separate field, filter on &lt;code&gt;AbortError&lt;/code&gt; there and skip the text entirely.&lt;/p&gt;

&lt;p&gt;I also wrote about the same class of noise from injected scripts in &lt;a href="https://www.mohamedgado.com/writing/gcrweb-firefox-injected-script-errors" rel="noopener noreferrer"&gt;&lt;code&gt;__gCrWeb&lt;/code&gt; and &lt;code&gt;__firefox__&lt;/code&gt; errors&lt;/a&gt;: code that isn't yours, reported as if it were.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is "signal is aborted without reason" a network error?
&lt;/h3&gt;

&lt;p&gt;No. The request was cancelled by code in the page calling &lt;code&gt;abort()&lt;/code&gt;. A network failure shows up as &lt;code&gt;TypeError: Failed to fetch&lt;/code&gt; in Chrome, not as an &lt;code&gt;AbortError&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does Firefox say "The operation was aborted" instead?
&lt;/h3&gt;

&lt;p&gt;The error is the same, a &lt;code&gt;DOMException&lt;/code&gt; named &lt;code&gt;AbortError&lt;/code&gt;. Each engine picks its own message text. Code that checks the name works everywhere, and code that checks the message works in one browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I report AbortError to my error tracker at all?
&lt;/h3&gt;

&lt;p&gt;Not a bare one. A cancel you started is expected behaviour. If you need to know how often a timeout fires, count it as a product event with the reason attached, and keep the error board for things that are actually broken.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>fetchapi</category>
      <category>errortracking</category>
    </item>
    <item>
      <title>wsrv.nl and robots.txt: every image in my sitemap was blocked for Google</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Fri, 27 Nov 2026 05:21:25 +0000</pubDate>
      <link>https://dev.to/mohamedgado/wsrvnl-and-robotstxt-every-image-in-my-sitemap-was-blocked-for-google-41ed</link>
      <guid>https://dev.to/mohamedgado/wsrvnl-and-robotstxt-every-image-in-my-sitemap-was-blocked-for-google-41ed</guid>
      <description>&lt;p&gt;Search Console read all four sitemaps of &lt;a href="https://www.mohamedgado.com/projects/reely" rel="noopener noreferrer"&gt;Reely&lt;/a&gt; with zero errors, so for weeks I logged them as clean. The warnings column next to it said something else: a warning on every single image entry. 787 of 787 in the core sitemap, 7,336 of 7,337 for movies, 5,772 of 5,772 for TV shows. The cause was the image proxy. Every poster URL went through &lt;a href="https://wsrv.nl" rel="noopener noreferrer"&gt;wsrv.nl&lt;/a&gt;, and wsrv.nl's robots.txt disallows any URL with a query string. A wsrv URL is nothing but a query string, so Googlebot-Image was not allowed to fetch a single one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the image host's robots.txt matters
&lt;/h2&gt;

&lt;p&gt;Google applies robots.txt per host. Your own robots.txt can allow everything, and it still says nothing about images served from another domain. When Googlebot-Image reads &lt;code&gt;&amp;lt;image:image&amp;gt;&lt;/code&gt; in your sitemap, or the &lt;code&gt;image&lt;/code&gt; field in your JSON-LD, it checks the robots.txt of the host in that URL before it fetches.&lt;/p&gt;

&lt;p&gt;Reely gets its posters from TMDB and resizes them through wsrv.nl, a free image proxy. A poster in the sitemap looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://wsrv.nl/?url=image.tmdb.org/t/p/original/abc.jpg&amp;amp;w=500&amp;amp;output=webp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What wsrv.nl's robots.txt says
&lt;/h2&gt;

&lt;p&gt;The file has two groups for &lt;code&gt;User-agent: *&lt;/code&gt;. The first one comes from Cloudflare's managed robots.txt and is friendly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="na"&gt;Content-Signal: search&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;yes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ai&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;train&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;use&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;reference&lt;/span&gt;
&lt;span class="nc"&gt;Allow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last lines of the file are the ones that matter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="nc"&gt;Disallow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="cm"&gt;/*?*
&lt;/span&gt;&lt;span class="nc"&gt;Allow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might read the first group as winning. It doesn't. Google merges every group that names the same user agent into one, and when an Allow and a Disallow both match a path, the longer rule wins. &lt;code&gt;/*?*&lt;/code&gt; is longer than &lt;code&gt;/&lt;/code&gt;, so any path with a &lt;code&gt;?&lt;/code&gt; in it is disallowed. Only the bare homepage (&lt;code&gt;/$&lt;/code&gt;) is explicitly allowed. That covers every image URL wsrv.nl can serve.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the warning count gave it away
&lt;/h2&gt;

&lt;p&gt;The warning text in Search Console is generic, and a few warnings on a sitemap are normal. What stood out was the exact match: the number of warnings in each file equalled the number of &lt;code&gt;&amp;lt;image:image&amp;gt;&lt;/code&gt; entries in that file. Pages had no warnings and images all did, in all three files. A broken page, a slow server or a bad tag doesn't hit every image in every sitemap. The only thing those images shared was the host.&lt;/p&gt;

&lt;p&gt;From there it took one request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s https://wsrv.nl/robots.txt &lt;span class="o"&gt;|&lt;/span&gt; tail -4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before the fix I had only looked at the errors field. My daily SEO script printed errors and skipped warnings, so the problem sat in plain sight for weeks.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: plain URLs for crawlers, the proxy for people
&lt;/h2&gt;

&lt;p&gt;I didn't drop wsrv.nl. It does a good job for visitors: it resizes, converts to WebP and caches at the edge. What changed is which URL goes where.&lt;/p&gt;

&lt;p&gt;TMDB serves fixed sizes from plain paths, and &lt;code&gt;image.tmdb.org/robots.txt&lt;/code&gt; returns a 404. Under the robots.txt rules, a missing robots.txt means everything is allowed. So I added one helper that builds the plain URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// For crawlers: a plain TMDB size, no query string.&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;crawlerImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'w500'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s1"&gt;'w1280'&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'w500'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="sb"&gt;`https://image.tmdb.org/t/p/${size}${path}`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything a crawler reads raw now uses it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the image sitemap entries&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;image&lt;/code&gt; field in the Movie, TVSeries and Person JSON-LD&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ItemList&lt;/code&gt; entries on collection pages&lt;/li&gt;
&lt;li&gt;the JSON-LD the Cloudflare Worker renders for titles that aren't prerendered&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On-page &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tags still go through wsrv.nl, because a person's browser doesn't read robots.txt. Open Graph and Twitter images also stay on wsrv.nl: link-preview bots from Facebook, X, Slack and Discord fetch those, and I check them with a separate unfurl probe.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check every host your crawlers touch
&lt;/h2&gt;

&lt;p&gt;This isn't only about wsrv.nl. Any image CDN, resizer or proxy you put in front of crawler-facing URLs has its own robots.txt, and the operator can change it at any time. A short list to check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pull every distinct host out of your sitemaps and structured data.&lt;/li&gt;
&lt;li&gt;Fetch &lt;code&gt;/robots.txt&lt;/code&gt; on each one. Look for &lt;code&gt;Disallow&lt;/code&gt; rules that match your URL shape, especially &lt;code&gt;/*?*&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Remember the merge rule. A friendly &lt;code&gt;Allow: /&lt;/code&gt; at the top doesn't help if a longer &lt;code&gt;Disallow&lt;/code&gt; comes later.&lt;/li&gt;
&lt;li&gt;In Search Console, read the warnings column on the Sitemaps report as well as errors. A warning count that equals your image count points at a systemic cause.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Google obeys the robots.txt of the image's own host, not yours.&lt;/li&gt;
&lt;li&gt;wsrv.nl disallows &lt;code&gt;/*?*&lt;/code&gt;, so every wsrv URL is blocked for Googlebot-Image.&lt;/li&gt;
&lt;li&gt;Use a plain, query-free origin URL in sitemaps and JSON-LD, and keep the proxy for on-page images.&lt;/li&gt;
&lt;li&gt;Warnings on every row of a sitemap mean one cause. Match the count against what the rows have in common.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the other half of getting pages into Google, see &lt;a href="https://www.mohamedgado.com/writing/discovered-currently-not-indexed" rel="noopener noreferrer"&gt;Discovered, currently not indexed&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>seo</category>
      <category>images</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Chrome/131.0 Safari/537.36: the fake browser behind my 503 hours</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Fri, 27 Nov 2026 05:20:49 +0000</pubDate>
      <link>https://dev.to/mohamedgado/chrome1310-safari53736-the-fake-browser-behind-my-503-hours-50p2</link>
      <guid>https://dev.to/mohamedgado/chrome1310-safari53736-the-fake-browser-behind-my-503-hours-50p2</guid>
      <description>&lt;p&gt;My health check failed one morning: 80 server errors served to real visitors in 24 hours, on a site that usually serves one or none. Almost all of them sat in two hours, 21:00 and 05:00 UTC. Googlebot, Applebot and Bingbot were among the clients that got a 503. The cause was one bot fleet sending 20,821 requests a day with this user agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0 Safari/537.36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look at the version: &lt;code&gt;Chrome/131.0&lt;/code&gt;. A real Chrome never sends that. Since user-agent reduction, Chrome always sends four parts with the last three zeroed, &lt;code&gt;Chrome/131.0.0.0&lt;/code&gt;. A two-part version is a hand-written string, so I could block it by exact match without any risk of blocking a person.&lt;/p&gt;

&lt;h2&gt;
  
  
  The symptom: 503s that were working as designed
&lt;/h2&gt;

&lt;p&gt;The site is &lt;a href="https://www.mohamedgado.com/projects/reely" rel="noopener noreferrer"&gt;Reely&lt;/a&gt;, a movie and TV catalogue on Cloudflare's free plan. Title pages get their data from TMDB. When TMDB rate-limits us, the Worker answers &lt;code&gt;503&lt;/code&gt; with a &lt;code&gt;Retry-After&lt;/code&gt; header instead of a broken page. That's deliberate: a crawler that gets a 503 comes back later, and one that gets a half-empty page may index it.&lt;/p&gt;

&lt;p&gt;So the 503s weren't a bug in the Worker. They were the overload path doing its job. The real question was what had pushed TMDB into rate-limiting us during those two hours. A burst of 5xx on a 503-by-design path is a load question, so I went looking for whoever caused the load.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step one: count only what browsers saw
&lt;/h2&gt;

&lt;p&gt;My first query grouped every 5xx in the zone by user agent, and the top rows were nonsense: 504s with no user agent at all. Those aren't visitors. Cloudflare logs its own internal traffic in the same dataset (Worker cache lookups, Early Hints, subrequests), and much of it carries synthetic statuses.&lt;/p&gt;

&lt;p&gt;Every request in the GraphQL Analytics API has a &lt;code&gt;requestSource&lt;/code&gt;, and only &lt;code&gt;eyeball&lt;/code&gt; means a real client. Filter on it before anything else:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;viewer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;zones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;zoneTag&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;zone id&amp;gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;httpRequestsAdaptiveGroups&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
        &lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="n"&gt;datetime_geq&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-24T21:00:00Z"&lt;/span&gt;
          &lt;span class="n"&gt;datetime_lt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-24T22:00:00Z"&lt;/span&gt;
          &lt;span class="n"&gt;requestSource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"eyeball"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;orderBy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;count_DESC&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt;
        &lt;span class="n"&gt;dimensions&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;userAgent&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step two: compare a burst hour to a quiet hour
&lt;/h2&gt;

&lt;p&gt;I ran that query twice: once for a burst hour and once for a normal one. In the burst hours, one string sat at the top with 2,637 and 1,864 requests an hour. In the quiet hours (10:00, 15:00 and 23:00 UTC) it wasn't there at all. Over the whole day it sent 20,821 requests, the second-largest user agent in the zone.&lt;/p&gt;

&lt;p&gt;A real browser population doesn't behave like that. People arrive all day, spread over hundreds of slightly different user-agent strings. A fleet arrives at once, from one string, and leaves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step three: confirm it can't be a person
&lt;/h2&gt;

&lt;p&gt;The malformed version settled it. Chrome's user-agent reduction froze the minor, build and patch numbers at zero years ago, so every real Chrome 131 sends &lt;code&gt;Chrome/131.0.0.0&lt;/code&gt;. &lt;code&gt;Chrome/131.0&lt;/code&gt; comes from someone typing a user agent into a scraper config. An exact match on the full string can't catch a real browser.&lt;/p&gt;

&lt;p&gt;I've since seen the same string, and a &lt;code&gt;Chrome/133&lt;/code&gt; sibling, on a &lt;a href="https://www.mohamedgado.com/projects/social-media-downloader" rel="noopener noreferrer"&gt;second site&lt;/a&gt; of mine. There it probes &lt;code&gt;/phpinfo.php&lt;/code&gt;, &lt;code&gt;/.env.php&lt;/code&gt; and &lt;code&gt;wp-config&lt;/code&gt; backups. It's a common scanner, not something aimed at one site.&lt;/p&gt;

&lt;h2&gt;
  
  
  The block
&lt;/h2&gt;

&lt;p&gt;The rule goes into a list of frozen, known-bad strings that my WAF script compiles into one Cloudflare custom rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;STALE_BROWSER_UAS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="c1"&gt;// 20,821 requests on 24 Nov, all in two bursts. Real Chrome sends 131.0.0.0.&lt;/span&gt;
  &lt;span class="s1"&gt;'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0 Safari/537.36'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;uaEqAny&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uas&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;uas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ua&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="sb"&gt;`(http.user_agent eq "${ua}")`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;' or '&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An exact &lt;code&gt;eq&lt;/code&gt; match is cheaper and safer than a regex. It can't spread to a user agent you didn't mean, and it fits the free plan's custom-rule limits.&lt;/p&gt;

&lt;p&gt;After applying it I checked from the outside. The fleet's string got a plain &lt;code&gt;403&lt;/code&gt;, and a current Chrome still got a &lt;code&gt;200&lt;/code&gt; on the same pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't read a 403 as a block
&lt;/h2&gt;

&lt;p&gt;My first check was wrong. A bare &lt;code&gt;curl&lt;/code&gt; with a current Chrome user agent also got a 403 on a title page, and I thought the new rule was misfiring. It wasn't. My site already shows a managed challenge to suspicious clients on detail pages, and a challenge also answers 403. The header tells them apart: a challenge carries &lt;code&gt;cf-mitigated: challenge&lt;/code&gt;, and a block doesn't.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -sI -A &lt;span class="s2"&gt;"&amp;lt;user agent&amp;gt;"&lt;/span&gt; https://example.com/page &lt;span class="o"&gt;|&lt;/span&gt; grep -i cf-mitigated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Filter Cloudflare analytics on &lt;code&gt;requestSource: "eyeball"&lt;/code&gt; before reading any 5xx count.&lt;/li&gt;
&lt;li&gt;Compare the top user agents in a burst hour with a quiet hour. A fleet appears in one and not the other.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Chrome/131.0&lt;/code&gt; (two parts) isn't a real Chrome. Reduced Chrome always sends &lt;code&gt;131.0.0.0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Block known-bad strings by exact match, never by a broad pattern.&lt;/li&gt;
&lt;li&gt;Tell a block from a challenge by &lt;code&gt;cf-mitigated&lt;/code&gt;, not by the status code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For another case of crawlers hiding in plain sight, see &lt;a href="https://www.mohamedgado.com/writing/meta-externalagent-webindexer-analytics" rel="noopener noreferrer"&gt;meta-externalagent and meta-webindexer&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cloudflare</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Flutter exact alarm permission on Android 14: stop the jump to Settings</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Thu, 26 Nov 2026 22:18:13 +0000</pubDate>
      <link>https://dev.to/mohamedgado/flutter-exact-alarm-permission-on-android-14-stop-the-jump-to-settings-49jk</link>
      <guid>https://dev.to/mohamedgado/flutter-exact-alarm-permission-on-android-14-stop-the-jump-to-settings-49jk</guid>
      <description>&lt;p&gt;&lt;a href="https://www.mohamedgado.com/projects/hadeed" rel="noopener noreferrer"&gt;Hadeed&lt;/a&gt;, my offline gym log, has a rest timer. You finish a set, tap "Set done", put the phone in your pocket, and it rings when rest is over. On my Android 14 phone, the first "Set done" of every session did something else: it opened Android's &lt;strong&gt;Alarms &amp;amp; reminders&lt;/strong&gt; settings page and threw me out of the app mid-set. The call behind it, &lt;code&gt;requestExactAlarmsPermission()&lt;/code&gt; from flutter_local_notifications, had been there since the first commit. Fixing it uncovered a second bug underneath. Without that permission, an &lt;code&gt;alarmClock&lt;/code&gt; schedule never rang at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why requestExactAlarmsPermission opens Settings
&lt;/h2&gt;

&lt;p&gt;Exact alarms are a special permission on Android 12 and later. There's no runtime dialog for &lt;code&gt;SCHEDULE_EXACT_ALARM&lt;/code&gt;. The only way to "request" it is to send the user to a system settings page where they flip a switch for your app. On Android 14, apps that aren't alarm clocks or calendars start with this permission denied.&lt;/p&gt;

&lt;p&gt;flutter_local_notifications exposes this as &lt;code&gt;requestExactAlarmsPermission()&lt;/code&gt;. It reads like a permission prompt, but on a real phone it opens Settings. My rest timer asked for it every time it scheduled the alarm, so every session started with a trip to Settings.&lt;/p&gt;

&lt;p&gt;The unit tests never caught it. They all mocked the plugin's platform channel, so a call to &lt;code&gt;requestExactAlarmsPermission&lt;/code&gt; just returned a value. Nothing checked what that call does on a device.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why USE_EXACT_ALARM wasn't an option
&lt;/h2&gt;

&lt;p&gt;Android also has &lt;code&gt;USE_EXACT_ALARM&lt;/code&gt;, which is granted at install and needs no switch. Google Play restricts it to apps whose core function is an alarm clock or a calendar, and the Play Console declaration offers exactly those two choices. A gym log is neither, so I removed &lt;code&gt;USE_EXACT_ALARM&lt;/code&gt; before the first closed test. That left &lt;code&gt;SCHEDULE_EXACT_ALARM&lt;/code&gt;, which Play allows but the user must turn on, so for most users it's off.&lt;/p&gt;

&lt;h2&gt;
  
  
  The second bug: alarmClock without the permission
&lt;/h2&gt;

&lt;p&gt;The rest alarm was scheduled with &lt;code&gt;AndroidScheduleMode.alarmClock&lt;/code&gt;, which needs exact-alarm permission. Without it, &lt;code&gt;zonedSchedule&lt;/code&gt; throws. My &lt;code&gt;schedule()&lt;/code&gt; caught and logged errors, so nothing crashed. The alarm just never got scheduled.&lt;/p&gt;

&lt;p&gt;So for everyone who declined the Settings page, or backed out of it, the rest timer was silent once the screen was off. The first bug hid the second: the Settings jump at least gave people a chance to grant the permission. Removing it without fixing the schedule mode would have made the alarm silent for nearly everyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: check, then fall back to an inexact alarm
&lt;/h2&gt;

&lt;p&gt;Three changes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Never call &lt;code&gt;requestExactAlarmsPermission()&lt;/code&gt; inside a flow.&lt;/strong&gt; The permission request now asks for notification permission only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check before scheduling.&lt;/strong&gt; &lt;code&gt;canScheduleExactNotifications()&lt;/code&gt; tells you whether exact alarms are allowed, without leaving the app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pick the schedule mode from that answer.&lt;/strong&gt; Use &lt;code&gt;alarmClock&lt;/code&gt; when it's allowed, and &lt;code&gt;inexactAllowWhileIdle&lt;/code&gt; when it isn't.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nc"&gt;Future&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;requestPermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// No requestExactAlarmsPermission here: on Android 14 it opens system&lt;/span&gt;
  &lt;span class="c1"&gt;// Settings. schedule() falls back to an inexact alarm instead.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;android&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestNotificationsPermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;Future&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;canExact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;android&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;canScheduleExactNotifications&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;AndroidScheduleMode&lt;/span&gt; &lt;span class="nf"&gt;restAlarmMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;canExact&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;canExact&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nc"&gt;AndroidScheduleMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alarmClock&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AndroidScheduleMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inexactAllowWhileIdle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in the schedule call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;plugin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zonedSchedule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;when&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;details&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;androidScheduleMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;restAlarmMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;canExact&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;canExact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An inexact alarm can fire a little late when the phone is in Doze. For a 90-second rest timer that's a fair trade against never ringing. People who want it exact can still grant the permission from the app's settings screen, where opening Settings is what they asked for.&lt;/p&gt;

&lt;p&gt;Hadeed's weekly training reminder already used this "exact if allowed, otherwise inexact" pattern. The rest alarm was the one place that didn't.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test what must NOT be called
&lt;/h2&gt;

&lt;p&gt;The mocked platform channel was the reason this survived so long, so the new tests use the same mock to check the reverse. One asserts that a method is never sent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'asking for permission never opens system Settings'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;RestAlarm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestPermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sentMethods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;isNot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'requestExactAlarmsPermission'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'without exact-alarm permission it still schedules, inexact'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;exactAllowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;RestAlarm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;scheduledArgs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'scheduleMode'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'inexactAllowWhileIdle'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both failed against the old code and pass with the fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist for exact alarms in Flutter
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Don't call &lt;code&gt;requestExactAlarmsPermission()&lt;/code&gt; from a flow the user is in the middle of. It opens a settings page, not a dialog.&lt;/li&gt;
&lt;li&gt;Call &lt;code&gt;canScheduleExactNotifications()&lt;/code&gt; before every schedule, and choose &lt;code&gt;alarmClock&lt;/code&gt; or &lt;code&gt;inexactAllowWhileIdle&lt;/code&gt; from the result.&lt;/li&gt;
&lt;li&gt;Don't declare &lt;code&gt;USE_EXACT_ALARM&lt;/code&gt; unless your app really is an alarm clock or a calendar. Play checks.&lt;/li&gt;
&lt;li&gt;Make sure a failed &lt;code&gt;zonedSchedule&lt;/code&gt; is visible somewhere. A caught-and-logged error here means a silent alarm.&lt;/li&gt;
&lt;li&gt;Run permission flows on a real Android 14 phone once. A mocked channel can't show you a settings page.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;On Android 14, exact-alarm permission starts denied for most apps, and asking for it means leaving your app.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;alarmClock&lt;/code&gt; without that permission doesn't fall back by itself. It throws, and the alarm never rings.&lt;/li&gt;
&lt;li&gt;Check, then degrade: exact when allowed, &lt;code&gt;inexactAllowWhileIdle&lt;/code&gt; otherwise.&lt;/li&gt;
&lt;li&gt;When a test mocks a platform call, also assert the calls that must never be made.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>android</category>
      <category>notifications</category>
    </item>
    <item>
      <title>expo-screen-capture and READ_MEDIA_IMAGES: the Play fix that crashed Android 14</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Thu, 26 Nov 2026 22:17:37 +0000</pubDate>
      <link>https://dev.to/mohamedgado/expo-screen-capture-and-readmediaimages-the-play-fix-that-crashed-android-14-5amd</link>
      <guid>https://dev.to/mohamedgado/expo-screen-capture-and-readmediaimages-the-play-fix-that-crashed-android-14-5amd</guid>
      <description>&lt;p&gt;&lt;a href="https://www.mohamedgado.com/projects/nafis" rel="noopener noreferrer"&gt;Nafis&lt;/a&gt;, my gold and precious-metals app, has an opt-in "secure screen" setting that hides the app from screenshots and the recent-apps preview. It uses &lt;code&gt;expo-screen-capture&lt;/code&gt;. On 27 August 2026 Google Play refused an upload because of a photo permission the app never asked for. I blocked the permission, plus its sibling, and the next upload went through. The day after, that release crashed on launch for every Android 14+ user. Here's the chain, and how to block expo-screen-capture's permissions without the crash.&lt;/p&gt;

&lt;h2&gt;
  
  
  Play rejects READ_MEDIA_IMAGES
&lt;/h2&gt;

&lt;p&gt;The rejection said:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;All developers requesting access to the photo and video permissions are required to tell Google Play about the core functionality of their app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nafis doesn't read photos. The permission came from &lt;code&gt;expo-screen-capture&lt;/code&gt;, which declares &lt;code&gt;READ_MEDIA_IMAGES&lt;/code&gt; for its screenshot listener (&lt;code&gt;addScreenshotListener&lt;/code&gt;). On Android 13 and below, it detects a screenshot by watching the media store for new images. Nafis only calls &lt;code&gt;preventScreenCaptureAsync()&lt;/code&gt;, which sets &lt;code&gt;FLAG_SECURE&lt;/code&gt; on the window and needs no permission at all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secureScreen&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;preventScreenCaptureAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;allowScreenCaptureAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;secureScreen&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So I added the library's permissions to &lt;code&gt;blockedPermissions&lt;/code&gt; in &lt;code&gt;app.json&lt;/code&gt;: &lt;code&gt;READ_MEDIA_IMAGES&lt;/code&gt;, and also &lt;code&gt;DETECT_SCREEN_CAPTURE&lt;/code&gt;, the Android 14 half of the same listener. The upload was accepted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking the manifest: read the AAB, not the installed app
&lt;/h2&gt;

&lt;p&gt;Before resubmitting, I wanted to confirm the permission was gone. &lt;code&gt;adb shell dumpsys package&lt;/code&gt; on the installed app didn't list &lt;code&gt;READ_MEDIA_IMAGES&lt;/code&gt;, but it didn't list it for the old build either. The library declares it with &lt;code&gt;maxSdkVersion="33"&lt;/code&gt;, so on a newer phone the package manager drops it at install time.&lt;/p&gt;

&lt;p&gt;Play reads the bundle, so check the bundle. Unzip the &lt;code&gt;.aab&lt;/code&gt; and read &lt;code&gt;base/manifest/AndroidManifest.xml&lt;/code&gt;. In a bundle it's a protobuf file, so use bundletool, or &lt;code&gt;aapt2 dump xmltree&lt;/code&gt; on the APK it produces. That's the manifest Play's review sees.&lt;/p&gt;

&lt;h2&gt;
  
  
  Every Android 14 launch crashes
&lt;/h2&gt;

&lt;p&gt;The release built, uploaded and shipped. It also crashed on open for every user on Android 14 or newer. Logcat:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FATAL EXCEPTION: expo-updates-error-recovery
java.lang.SecurityException: Permission Denial: registerScreenCaptureObserver
  requires android.permission.DETECT_SCREEN_CAPTURE
    at android.app.Activity.registerScreenCaptureCallback(Activity.java:10037)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'd decided what to block by reading my own code, which never adds a screenshot listener. The library's code is what matters. On Android 14+, expo-screen-capture's native module registers a screen-capture callback as soon as the module is created, and again whenever the activity comes to the foreground. It doesn't wait for JavaScript to ask, and it doesn't catch a failure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nc"&gt;OnCreate&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;VERSION&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SDK_INT&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nc"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;VERSION_CODES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UPSIDE_DOWN_CAKE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;screenCaptureCallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Activity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ScreenCaptureCallback&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;emitEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;registerCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// calls Activity.registerScreenCaptureCallback&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;screenshotEventEmitter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ScreenshotEventEmitter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;emitEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;OnActivityEntersForeground&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;registerCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;screenshotEventEmitter&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onHostResume&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;registerScreenCaptureCallback&lt;/code&gt; needs &lt;code&gt;DETECT_SCREEN_CAPTURE&lt;/code&gt;. With that permission blocked, Android throws a &lt;code&gt;SecurityException&lt;/code&gt;, nothing catches it, and the app dies at launch. On Android 13 and below the library uses the older media-store path, which swallows its own failures. That's why the crash hit Android 14+ only.&lt;/p&gt;

&lt;p&gt;My first suspect was something else in the same commit, an &lt;code&gt;Updates.reloadAsync()&lt;/code&gt; call, because the exception's thread was named &lt;code&gt;expo-updates-error-recovery&lt;/code&gt;. The stack trace named the real cause in one line, once I reproduced the crash with a release build on an emulator.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: block one permission, keep the other
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;DETECT_SCREEN_CAPTURE&lt;/code&gt; is a normal permission, granted at install without a prompt, and Play doesn't ask about it. Only &lt;code&gt;READ_MEDIA_IMAGES&lt;/code&gt; triggers the photo-and-video declaration. So the fix was to unblock one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"android"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"blockedPermissions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"android.permission.READ_MEDIA_IMAGES"&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;READ_MEDIA_IMAGES&lt;/code&gt; blocked, the Android 13-and-below listener fails quietly, and the app never uses it anyway. With &lt;code&gt;DETECT_SCREEN_CAPTURE&lt;/code&gt; declared, the Android 14 registration succeeds. &lt;code&gt;preventScreenCaptureAsync()&lt;/code&gt; works on both, since &lt;code&gt;FLAG_SECURE&lt;/code&gt; never needed either permission.&lt;/p&gt;

&lt;h2&gt;
  
  
  The process gaps that let it ship
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No release build was launched before submitting.&lt;/strong&gt; The release went out 16 minutes after the commit, and the crash only exists in a build where the permission is actually missing. A single launch on an Android 14 device or emulator would have caught it. My release checklist now has that step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build and submit were one command.&lt;/strong&gt; When Play rejected the first upload, the whole build was thrown away. Splitting build, verify and submit turned the retry from a 15-minute rebuild into a 2-minute upload.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Play Vitals looked clean after 7 hours.&lt;/strong&gt; Crash reporting lags. An empty dashboard on release day doesn't mean the release is fine.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;blockedPermissions&lt;/code&gt; removes a permission your dependencies may use without asking you. Read where the library uses it before blocking it.&lt;/li&gt;
&lt;li&gt;expo-screen-capture registers its Android 14 screenshot callback at startup, whether or not you add a listener. Keep &lt;code&gt;DETECT_SCREEN_CAPTURE&lt;/code&gt;, and block only &lt;code&gt;READ_MEDIA_IMAGES&lt;/code&gt; if Play asks.&lt;/li&gt;
&lt;li&gt;Check permissions in the &lt;code&gt;.aab&lt;/code&gt; manifest. An installed app's &lt;code&gt;dumpsys&lt;/code&gt; hides permissions with a &lt;code&gt;maxSdkVersion&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A crash that only hits some Android versions usually lines up with an SDK check in some library's native code.&lt;/li&gt;
&lt;li&gt;Launch the release build once before you submit it.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>reactnative</category>
      <category>expo</category>
      <category>android</category>
    </item>
    <item>
      <title>expo-audio stops playing in the background? Check who set the audio mode</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Thu, 26 Nov 2026 22:17:01 +0000</pubDate>
      <link>https://dev.to/mohamedgado/expo-audio-stops-playing-in-the-background-check-who-set-the-audio-mode-2lio</link>
      <guid>https://dev.to/mohamedgado/expo-audio-stops-playing-in-the-background-check-who-set-the-audio-mode-2lio</guid>
      <description>&lt;p&gt;In &lt;a href="https://www.mohamedgado.com/projects/rafiq" rel="noopener noreferrer"&gt;Rafiq&lt;/a&gt;, my Quran app, people play a recitation, press home or lock the phone, and keep listening. One week that stopped working. Every player went quiet the moment the app left the screen: the Quran, the lectures, the daily dhikr. Nothing in the players had changed. The cause was a screen most people never open, calling &lt;code&gt;setAudioModeAsync&lt;/code&gt; with &lt;code&gt;shouldPlayInBackground: false&lt;/code&gt;. In expo-audio that call isn't about one player. It sets the mode for the whole app, and it stays set until something sets it again.&lt;/p&gt;

&lt;h2&gt;
  
  
  The symptom: every player pauses when the app goes to the background
&lt;/h2&gt;

&lt;p&gt;The report was simple: "audio stops when I leave the app, since the last release." It happened on every player, every time, on Android. The app's audio setup did ask for background playback, with &lt;code&gt;shouldPlayInBackground: true&lt;/code&gt; at startup. That's the part that made it confusing, since the setting was right when the app opened.&lt;/p&gt;

&lt;p&gt;The user's next message gave it away: "we meant to do that for the adhan only, not for any audio." Rafiq has a settings screen where you choose the muezzin for the call to prayer, and each voice has a play button so you can hear it first. That screen had its own audio setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cause: setAudioModeAsync is process-wide
&lt;/h2&gt;

&lt;p&gt;The adhan sound picker started each preview like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The picker's preview, before the fix&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;setAudioModeAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;playsInSilentMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;shouldPlayInBackground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// a 20 s preview shouldn't keep playing from a pocket&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;player&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createAudioPlayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The intent was reasonable. A 20-second preview of a muezzin shouldn't keep playing after you put the phone away. But &lt;code&gt;setAudioModeAsync&lt;/code&gt; doesn't configure that player. It configures the audio session for the whole process. On Android, expo-audio keeps a single &lt;code&gt;shouldPlayInBackground&lt;/code&gt; field in its native module, and pauses every playing player when the app goes to the background while that field is false. From expo-audio's &lt;code&gt;AudioModule.kt&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nc"&gt;AsyncFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"setAudioModeAsync"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AudioMode&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;shouldPlayInBackground&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shouldPlayInBackground&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;OnActivityEntersBackground&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;shouldPlayInBackground&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;allPlayables&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forEach&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;playable&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;playable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isPlaying&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;playable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isPaused&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;playable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pause&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So one visit to Settings → adhan sound → play turned background playback off for every player in the app, and it stayed off until the next cold start, because nothing wrote the mode again after startup. Users who never opened that screen never saw the bug, which is why it looked random.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it took longer than it should have
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"Since the last release" sent me to the wrong diff.&lt;/strong&gt; I read every audio change in the latest release looking for a new pause call. There wasn't one. The previews had shipped one release earlier. The report dated when people noticed, not when the code changed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An earlier cleanup had missed this caller.&lt;/strong&gt; A refactor had already moved three providers' &lt;code&gt;setAudioModeAsync&lt;/code&gt; calls into one place. It missed the fourth caller because it was in a component, not a provider. The refactor looked where audio setup was expected to live instead of searching the whole repo for the function name.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A comment made the bug look deliberate.&lt;/strong&gt; The line carried a comment explaining why the preview shouldn't play in the background. It read like a decision someone had thought through, so I skipped past it twice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same search turned up a second, quieter bug. When three providers each called &lt;code&gt;setAudioModeAsync&lt;/code&gt; on mount, the last one to run won. React runs child effects before parent effects, so the outermost provider always wrote last. One provider's &lt;code&gt;interruptionMode: 'mixWithOthers'&lt;/code&gt; had never taken effect.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: one owner for the audio mode
&lt;/h2&gt;

&lt;p&gt;Two changes. First, the preview stopped touching the session. It ends its own sound instead: when the sheet closes, when the component unmounts, and when the app goes to the background.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sub&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AppState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'change'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'background'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;stopPreview&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;stopPreview&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Second, one hook now owns the audio mode, and it sets the mode again every time the app comes back to the foreground. Nothing in the app can read the mode back, so a stray write would otherwise stay in place without anyone noticing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;useAudioSessionMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keepPlaying&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;apply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="nf"&gt;setAudioModeAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;playsInSilentMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;shouldPlayInBackground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;keepPlaying&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;interruptionMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'doNotMix'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reportError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sub&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AppState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'change'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'active'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;keepPlaying&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;keepPlaying&lt;/code&gt; combines the user's background-audio setting with whether the full adhan is playing, so the call to prayer still plays through a locked screen even for someone who turned background audio off. It's one value, and one hook writes it.&lt;/p&gt;

&lt;p&gt;A test pins the rule that this hook is the only caller of &lt;code&gt;setAudioModeAsync&lt;/code&gt;. If a future screen adds its own call, the test fails, so the bug can't come back silently.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to check your own app
&lt;/h2&gt;

&lt;p&gt;If expo-audio playback stops when your app goes to the background:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Search the whole repo for &lt;code&gt;setAudioModeAsync&lt;/code&gt;, not just your audio folder. Any call with &lt;code&gt;shouldPlayInBackground: false&lt;/code&gt; affects every player.&lt;/li&gt;
&lt;li&gt;Check the config plugin. On iOS, background audio also needs the &lt;code&gt;UIBackgroundModes&lt;/code&gt; &lt;code&gt;audio&lt;/code&gt; entry, which the expo-audio plugin adds when you enable background playback.&lt;/li&gt;
&lt;li&gt;Count the callers. With more than one, the last write wins, and effect order decides which one that is.&lt;/li&gt;
&lt;li&gt;If a single sound must not play in the background, stop that sound yourself on an &lt;code&gt;AppState&lt;/code&gt; &lt;code&gt;background&lt;/code&gt; event. Leave the session alone.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;setAudioModeAsync&lt;/code&gt; sets the mode for every player in the app, not for the one you're about to create.&lt;/li&gt;
&lt;li&gt;Give a process-wide setting exactly one caller, and pin that with a test.&lt;/li&gt;
&lt;li&gt;When a refactor's goal is "one owner", search the repo for the function name instead of the folders you expect it in.&lt;/li&gt;
&lt;li&gt;Set state you can't read back again on every return to the foreground.&lt;/li&gt;
&lt;li&gt;A bug report that says "since the last release" tells you when someone noticed, not when the code changed.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>reactnative</category>
      <category>expo</category>
      <category>android</category>
    </item>
    <item>
      <title>Cross-posting to dev.to, Hashnode and Medium with a canonical URL</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Thu, 26 Nov 2026 21:48:54 +0000</pubDate>
      <link>https://dev.to/mohamedgado/cross-posting-to-devto-hashnode-and-medium-with-a-canonical-url-44pj</link>
      <guid>https://dev.to/mohamedgado/cross-posting-to-devto-hashnode-and-medium-with-a-canonical-url-44pj</guid>
      <description>&lt;p&gt;Each article I write lives on my own site first, then gets a copy on dev.to, Hashnode and Medium. Each copy carries a canonical link back to the original, so the copies bring in readers without competing with it in search. A canonical is a hint to search engines, not a command, but it's the signal all three platforms support. Only dev.to has an API I can use, so the other two are a paste with a checklist. Here's the routine for 24 articles, and the spots where each platform quietly drops the canonical, the code blocks or the tables.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a canonical URL does on a cross-post
&lt;/h2&gt;

&lt;p&gt;A copy of an article on another domain is duplicate content. Search engines pick one version to rank. The canonical link (&lt;code&gt;&amp;lt;link rel="canonical" href="..."&amp;gt;&lt;/code&gt; in the copy's head) tells them which version you want them to pick. Without it, a big platform can outrank your own site with your own article.&lt;/p&gt;

&lt;p&gt;Each platform sets that tag from a field in the post settings. If you skip the field, the copy points to itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  dev.to: the API, with two traps
&lt;/h2&gt;

&lt;p&gt;dev.to (Forem) has a real API. One POST creates a published post with the canonical set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;devtoArticle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;body_markdown&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;published&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;canonical_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;devtoTags&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things bit me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The RSS import makes drafts, sometimes without the canonical.&lt;/strong&gt; If you connect your feed in dev.to's settings, new articles show up as drafts. My script publishes those drafts with the canonical filled in, instead of creating a second copy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Front matter beats the API field.&lt;/strong&gt; An imported draft's &lt;code&gt;body_markdown&lt;/code&gt; starts with front matter saying &lt;code&gt;published: false&lt;/code&gt;. A PUT that sends &lt;code&gt;published: true&lt;/code&gt; without a new body returns 200 and leaves the draft a draft. Send the body every time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;dev.to also limits how fast you can create posts. One every 35 seconds stays under it. Tags are capped at 4, lowercase, letters and digits only, so &lt;code&gt;Next.js&lt;/code&gt; becomes &lt;code&gt;nextjs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To never post twice, the script lists my posts and skips any article whose canonical URL or title already has a copy. Checking the title as well catches imported drafts that came in without a canonical.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hashnode: paste the Markdown, set the canonical by hand
&lt;/h2&gt;

&lt;p&gt;Hashnode's API and bulk import are Pro features, so on the free plan each post is a paste. My script writes a Markdown copy of each article with every site-relative link made absolute. A link to &lt;code&gt;/writing/x&lt;/code&gt; in a copy would otherwise point at Hashnode.&lt;/p&gt;

&lt;p&gt;In the post settings there are three fields to fill:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The canonical URL.&lt;/strong&gt; It's the "originally published" option in the article settings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The SEO title.&lt;/strong&gt; I use the same short title as the site's &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The SEO description.&lt;/strong&gt; Hashnode caps it at 150 characters. My site allows 160, and today's three articles ran 153 to 158, so each needed a trimmed copy. I now write descriptions at 150 or less so one version works everywhere.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To check what's already on Hashnode, the blog's RSS feed isn't enough: mine lists only the 20 newest posts, and a few Hashnode slugs differ from mine. The blog's sitemap lists every post. I fetch each URL and compare its canonical, which tells me which articles have a copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Medium: paste HTML, because the importer drops code
&lt;/h2&gt;

&lt;p&gt;Medium has no API for new integrations, and its "import a story" tool dropped every code block from my pages. For a technical blog that rules it out. What works is pasting HTML into the editor, so the script also writes a plain HTML copy of each article, with three fixes for Medium's editor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;plainHtml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;markdown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;unified&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;remarkParse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;remarkGfm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;remarkRehype&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tablesToLists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rehypeStringify&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;markdown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Medium splits a code block into separate boxes at every empty line.&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;pre&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;\&lt;span class="n"&gt;s&lt;/span&gt;\&lt;span class="no"&gt;S&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;*?&amp;lt;&lt;/span&gt;\&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pre&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pre&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;pre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="nf"&gt;n&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;?=&lt;/span&gt;\&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'\n '&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// The Windows HTML clipboard garbles raw UTF-8, so non-ASCII goes in as entities.&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;\&lt;span class="n"&gt;x00&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;\&lt;span class="n"&gt;x7f&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;gu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="sb"&gt;`&amp;amp;#${ch.codePointAt(0)};`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tables become lists.&lt;/strong&gt; Medium has no tables, and pasted cells run together into one line. A small rehype plugin turns each row into a bullet like "&lt;strong&gt;RSC payload&lt;/strong&gt; — 280 KB".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Empty lines inside code get a no-break space&lt;/strong&gt;, so each code block stays one box.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-ASCII becomes HTML entities&lt;/strong&gt;, because the clipboard step mangles UTF-8.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Windows, &lt;code&gt;Set-Clipboard -AsHtml&lt;/code&gt; puts the file on the clipboard as rich HTML. That switch exists only in Windows PowerShell 5.1, not in PowerShell 7, so call it through &lt;code&gt;powershell.exe&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;powershell&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NoProfile&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Command&lt;/span&gt; &lt;span class="s2"&gt;"Set-Clipboard -AsHtml -Value (Get-Content -Raw 'article.html')"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then type the title, press Enter and paste. Before publishing, I count the &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; elements in the editor against the code blocks in the source.&lt;/p&gt;

&lt;p&gt;Medium's canonical setting is only in the story's settings page after publishing: &lt;strong&gt;Advanced Settings → "This story was originally published elsewhere"&lt;/strong&gt;, then &lt;strong&gt;Edit canonical link&lt;/strong&gt;, paste the URL, &lt;strong&gt;Save canonical link&lt;/strong&gt;. Topics allow 5 per story and 25 characters each. Commas don't separate them; press Enter after each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the canonical on the live copy
&lt;/h2&gt;

&lt;p&gt;A form that says "saved" isn't proof. For each copy, I read the canonical from the published page:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;dev.to and Hashnode:&lt;/strong&gt; fetch the post URL and read &lt;code&gt;link[rel=canonical]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Medium:&lt;/strong&gt; it returns 403 to scripted requests, so I run the same fetch from a tab that's already open on medium.com and parse the HTML there.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/p/&amp;lt;post-id&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DOMParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parseFromString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'text/html'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'link[rel=canonical]'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'href'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That check, plus a code block count per copy, is what I call done. Every copy URL also goes into a dated note in the repo, so nothing gets posted twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write once on your own domain, and give every copy a canonical link back to it.&lt;/li&gt;
&lt;li&gt;dev.to: use the API, and send the body on every update, because its front matter beats the &lt;code&gt;published&lt;/code&gt; field.&lt;/li&gt;
&lt;li&gt;Hashnode on the free plan: paste Markdown with absolute links, and keep descriptions at 150 characters or less.&lt;/li&gt;
&lt;li&gt;Medium: paste HTML, not the importer. Turn tables into lists, set the canonical after publishing, then read it back from the live page.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>seo</category>
      <category>blogging</category>
      <category>automation</category>
    </item>
    <item>
      <title>Bing Webmaster API ThrottleUser and ThrottleIP: what each refusal means</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Thu, 26 Nov 2026 21:48:19 +0000</pubDate>
      <link>https://dev.to/mohamedgado/bing-webmaster-api-throttleuser-and-throttleip-what-each-refusal-means-3i38</link>
      <guid>https://dev.to/mohamedgado/bing-webmaster-api-throttleuser-and-throttleip-what-each-refusal-means-3i38</guid>
      <description>&lt;p&gt;The Bing Webmaster API has two throttle errors that look alike and mean different things. &lt;code&gt;ERROR!!! ThrottleIP&lt;/code&gt; is about where the call comes from: Bing refused every call my Cloudflare Worker made, while the same key worked from any other machine. &lt;code&gt;ERROR!!! ThrottleUser&lt;/code&gt; is about the account and the call: on 26 November Bing answered my sitemap submit (&lt;code&gt;SubmitFeed&lt;/code&gt;) with &lt;code&gt;400 ThrottleUser&lt;/code&gt; from Cloudflare's build servers and from my home connection, while other calls with the same key, from the same machine, in the same minute, returned 200. Neither one means the key is wrong, and neither one is a reason to fail a deploy. Treating ThrottleUser as a failure is what broke my deploy script.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does ERROR!!! ThrottleIP mean?
&lt;/h2&gt;

&lt;p&gt;Bing is refusing the IP address the request came from. My daily index report ran inside a Cloudflare Worker and asked Bing for crawl stats. On 19 November, 20 of 20 calls came back &lt;code&gt;ThrottleIP&lt;/code&gt;. The same API key, from my laptop, worked on the first try.&lt;/p&gt;

&lt;p&gt;Cloudflare Workers make outbound requests from shared egress IPs, the same addresses thousands of other Workers use. Bing appears to rate-limit those addresses as a group, so your own call volume doesn't matter. You can't fix it with backoff. Move the call somewhere with its own IP. Mine now runs as a daily GitHub Actions job (&lt;code&gt;pnpm check:bing&lt;/code&gt;), and the Worker no longer calls Bing at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does ERROR!!! ThrottleUser mean?
&lt;/h2&gt;

&lt;p&gt;This one followed the account, not the network. The response body was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"ErrorCode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"Message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"ERROR!!! ThrottleUser"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I could pin down, all with the same key:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Call&lt;/th&gt;
&lt;th&gt;From&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;SubmitFeed&lt;/code&gt; (sitemap)&lt;/td&gt;
&lt;td&gt;Cloudflare Workers Builds&lt;/td&gt;
&lt;td&gt;400 ThrottleUser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;SubmitFeed&lt;/code&gt; (sitemap)&lt;/td&gt;
&lt;td&gt;Home connection&lt;/td&gt;
&lt;td&gt;400 ThrottleUser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GetUrlSubmissionQuota&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Home connection&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;SubmitUrlBatch&lt;/code&gt; (3 URLs)&lt;/td&gt;
&lt;td&gt;Home connection&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So it isn't the IP and it isn't the key. Bing is refusing that call for that site. A deploy earlier the same day had submitted the same sitemap successfully, and Bing already knew the sitemap. My reading is that Bing limits how often you can resubmit a sitemap it already has. Bing doesn't document the window, so I don't depend on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the throttle broke my deploy
&lt;/h2&gt;

&lt;p&gt;Each deploy runs a script that tells search engines what changed:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;IndexNow gets the URLs whose content changed (Bing, Yandex, Seznam and Naver read it).&lt;/li&gt;
&lt;li&gt;Google Search Console and Bing get the sitemap, but only when a URL or a &lt;code&gt;lastmod&lt;/code&gt; moved.&lt;/li&gt;
&lt;li&gt;A D1 table records each URL's fingerprint and &lt;code&gt;lastmod&lt;/code&gt;, so the next deploy can tell what moved.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The script had one rule for step 2: if any engine refused the sitemap, keep the old &lt;code&gt;lastmod&lt;/code&gt; values so the next deploy retries. That's reasonable for an outage. Against a throttle it never settles. Three new articles went out, Google accepted the sitemap with a 204, Bing said ThrottleUser, and the three rows kept a &lt;code&gt;null&lt;/code&gt; lastmod. The next deploy saw the sitemap as changed again, pinged both engines again, and got the same refusal from Bing.&lt;/p&gt;

&lt;p&gt;Nothing was visibly broken. The articles were live, and IndexNow had already sent them to Bing with a 200. The only sign was three nulls in a table. A query for &lt;code&gt;lastmod IS NULL&lt;/code&gt; found exactly the three newest pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: a throttle is a skip
&lt;/h2&gt;

&lt;p&gt;The outcome of a sitemap submit now has three values, and only a real refusal counts as a failure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * Bing SubmitFeed result as 'ok' | 'skipped' | 'failed'. A throttle is a skip: Bing re-reads a
 * sitemap it already has, and IndexNow already carries the changed URLs.
 */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;bingFeedOutcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="no"&gt;ERROR&lt;/span&gt;&lt;span class="o"&gt;!!!&lt;/span&gt; &lt;span class="nc"&gt;Throttle&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'skipped'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'failed'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the deploy script, a skip prints a notice instead of an error, and the &lt;code&gt;lastmod&lt;/code&gt; values are saved:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;outcome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;bingFeedOutcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outcome&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'skipped'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`::notice::Bing sitemap throttled, already known to Bing: ${text.slice(0, 200)}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outcome&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'failed'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;outcome&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An invalid key or a 500 still fails and still holds the &lt;code&gt;lastmod&lt;/code&gt; values back for a retry. The test pins both sides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'bingFeedOutcome: 200 is ok, a Throttle* refusal is skipped, any other refusal fails'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bingFeedOutcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'{"d":null}'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bingFeedOutcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'{"ErrorCode":4,"Message":"ERROR!!! ThrottleUser"}'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'skipped'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bingFeedOutcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'{"Message":"ERROR!!! ThrottleIP"}'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'skipped'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bingFeedOutcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'{"Message":"ERROR!!! InvalidApiKey"}'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'failed'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bingFeedOutcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Throttle in an HTML error page'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'failed'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the fix, one run saved the four pending rows, and the next dry run reported &lt;code&gt;sitemap unchanged&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read Bing's message, not just the status
&lt;/h2&gt;

&lt;p&gt;Bing returns 400 for a bad key, a throttle and a malformed request alike. The reason is in the body's &lt;code&gt;Message&lt;/code&gt; field. My API client puts it in every error it throws:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Message&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An error that says &lt;code&gt;bing GetCrawlStats 400 ERROR!!! ThrottleIP&lt;/code&gt; sends you to the right fix on the first read. A bare &lt;code&gt;400&lt;/code&gt; would have me checking the key first.&lt;/p&gt;

&lt;h2&gt;
  
  
  You may not need SubmitFeed on every deploy
&lt;/h2&gt;

&lt;p&gt;Bing gets new and changed URLs in two other ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;IndexNow.&lt;/strong&gt; Any change goes out at deploy time, and it doesn't depend on the sitemap call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SubmitUrlBatch.&lt;/strong&gt; It's the Webmaster API's own URL submit, with a quota of 10,000 a day on my site (&lt;code&gt;GetUrlSubmissionQuota&lt;/code&gt; reports yours).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once Bing knows your sitemap, it re-reads it on its own schedule. Resubmitting it on every deploy mostly earns throttles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ThrottleIP&lt;/code&gt; is about where the call comes from. Shared egress such as Cloudflare Workers gets it, so call Bing from somewhere with its own IP.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ThrottleUser&lt;/code&gt; followed the account and the call (&lt;code&gt;SubmitFeed&lt;/code&gt;), not the IP or the key. Other calls kept working.&lt;/li&gt;
&lt;li&gt;If a failed submit holds back state for a retry, a throttle must not count as a failure, or the retry repeats forever.&lt;/li&gt;
&lt;li&gt;Check the stored state after the first deploy that adds pages. A null &lt;code&gt;lastmod&lt;/code&gt; was the only sign of this one.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>seo</category>
      <category>bing</category>
      <category>cloudflare</category>
    </item>
    <item>
      <title>Next.js ships dangerouslySetInnerHTML twice: once in the HTML, once in the RSC payload</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Thu, 26 Nov 2026 17:03:18 +0000</pubDate>
      <link>https://dev.to/mohamedgado/nextjs-ships-dangerouslysetinnerhtml-twice-once-in-the-html-once-in-the-rsc-payload-254a</link>
      <guid>https://dev.to/mohamedgado/nextjs-ships-dangerouslysetinnerhtml-twice-once-in-the-html-once-in-the-rsc-payload-254a</guid>
      <description>&lt;p&gt;In the Next.js App Router, a server component that renders HTML with &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt; sends that HTML twice: once in the page's HTML, and again, escaped as a string, in the inline React Server Components payload that hydration reads. For a long markdown article the payload copy can be bigger than the article. One of my case-study pages was 512 KB of HTML against a 520 KB budget: 181 KB of article and 280 KB of RSC payload. Sending each body only once, in the static HTML, brought that page to 262 KB without removing a word or an image.&lt;/p&gt;

&lt;p&gt;This is Next.js 16.4 with React 19.3, statically exported. The mechanism applies to any App Router page that renders a big HTML string from a server component.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does the RSC payload contain my HTML?
&lt;/h2&gt;

&lt;p&gt;The HTML the server sends is not all React needs. To hydrate, and to render later client-side navigations without a full load, React also needs the component tree as data: the RSC payload. In a static or server-rendered App Router page it's inlined at the bottom of the HTML as a series of &lt;code&gt;self.__next_f.push([...])&lt;/code&gt; script calls.&lt;/p&gt;

&lt;p&gt;Props are part of that tree. &lt;code&gt;dangerouslySetInnerHTML={{ __html: html }}&lt;/code&gt; is a prop whose value is your whole rendered article, so the article goes into the payload as one long JSON string, with every quote and angle bracket escaped. Escaping makes the payload copy bigger than the HTML copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to see it on your own page
&lt;/h2&gt;

&lt;p&gt;Weigh the parts of the built HTML instead of guessing. Sum the &lt;code&gt;self.__next_f.push&lt;/code&gt; script bodies, then measure the article element on its own. On my page:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RSC payload&lt;/td&gt;
&lt;td&gt;280 KB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Article (59 KB of text, 122 KB of markup)&lt;/td&gt;
&lt;td&gt;181 KB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Everything else&lt;/td&gt;
&lt;td&gt;~50 KB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One trap: if the article itself quotes &lt;code&gt;self.__next_f.push(...)&lt;/code&gt;, as this one does, a regex over the page matches the prose as well. Count only inside &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;

&lt;p&gt;My first idea was trimming the image markup (long CDN URLs, alt text repeated in &lt;code&gt;aria-label&lt;/code&gt;). That's about 20% of the article and does nothing about the copy, which grows with every section the article gains.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: render an empty marker, fill it after the build
&lt;/h2&gt;

&lt;p&gt;The body only has to be in the HTML. Nothing on the client reads it from the payload. So in production the component writes the HTML to disk at build time and renders an empty element with an id:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;StaticHtml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;className&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;NODE_ENV&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'production'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;div&lt;/span&gt; &lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;__html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;recordStaticHtml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;div&lt;/span&gt;
      &lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="n"&gt;suppressHydrationWarning&lt;/span&gt;
      &lt;span class="n"&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;__html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The payload now carries an empty string. &lt;code&gt;recordStaticHtml&lt;/code&gt; writes the body to &lt;code&gt;.next/static-html/&amp;lt;id&amp;gt;.html&lt;/code&gt;. &lt;code&gt;next dev&lt;/code&gt; has no post-build step, so in development the component renders the HTML directly.&lt;/p&gt;

&lt;p&gt;A script runs right after &lt;code&gt;next build&lt;/code&gt; and writes each body into its marker in the exported HTML files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MARKER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;div&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;script&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;\&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;^&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;\&lt;span class="n"&gt;bdata&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"([^"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"[^&amp;gt;]*&amp;gt;)&amp;lt;\/\2&amp;gt;/g

export function injectStaticHtml(page, lookup) {
  const filled = []
  const missing = []
  const html = page.replace(MARKER, (whole, open, tag, id) =&amp;gt; {
    const body = lookup(id)
    if (body == null) {
      missing.push(id)
      return whole
    }
    filled.push(id)
    return `${open}${body}&amp;lt;/${tag}&amp;gt;`
  })
  return { html, filled, missing }
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's wired into the build script (&lt;code&gt;next build &amp;amp;&amp;amp; node scripts/inline-static-html.mjs&lt;/code&gt;), and it fails the build in two cases. A marker with no recorded body would ship an empty article. Zero markers across the whole site means the component stopped recording, and the pages would quietly go back to the doubled size.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does hydration wipe the body?
&lt;/h2&gt;

&lt;p&gt;No. When React hydrates an element with &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt;, it doesn't rewrite the element's children to match the prop, so the static body stays in place. &lt;code&gt;suppressHydrationWarning&lt;/code&gt; silences the dev warning about the difference. I checked this on a real production build served locally, not by reasoning: after hydration the page still had all 13 &lt;code&gt;h2&lt;/code&gt;s and 83 images, and the console showed no hydration warnings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Client-side navigation gets the empty marker
&lt;/h2&gt;

&lt;p&gt;A full page load is covered. A &lt;code&gt;&amp;lt;Link&amp;gt;&lt;/code&gt; click is not. The App Router renders the next page from its RSC payload (the &lt;code&gt;.txt&lt;/code&gt; file next to the HTML), and that payload now holds an empty body.&lt;/p&gt;

&lt;p&gt;The first version handled this by reloading the page once. It worked, but a full load throws away the JS heap, the scroll restoration and the instant feel that client navigation exists for. The second version fetches the page's own static HTML and copies each body in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fillStaticHtml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;markers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;querySelectorAll&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;HTMLElement&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;EMPTY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;markers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="o"&gt;/&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'/'&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;warmPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DOMParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parseFromString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'text/html'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;bodies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;querySelectorAll&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;HTMLElement&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;MARKER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;staticHtml&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;innerHTML&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;filled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fillMarkers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;markers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;bodies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispatchEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;FILLED_EVENT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;hasEmptyMarker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That HTML file is cached at the CDN (about 49 KB brotli for the biggest page). A small client component starts the fetch on &lt;code&gt;pointerover&lt;/code&gt;, &lt;code&gt;touchstart&lt;/code&gt; or &lt;code&gt;focusin&lt;/code&gt; of an article link, so it usually lands before the click does. The reload stayed as a fallback, guarded by a &lt;code&gt;sessionStorage&lt;/code&gt; key so a broken build can't loop. If it fires, it reports an error to analytics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anything that reads the article DOM has to re-run
&lt;/h2&gt;

&lt;p&gt;When the body is filled after mount, anything that read the article on mount has read an empty one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The section rail and the outline observers&lt;/strong&gt; would find no headings. They re-run when the fill event fires, through a hook that bumps a counter on &lt;code&gt;static-html:filled&lt;/code&gt;, and that counter sits in their effect deps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The read beacon&lt;/strong&gt;, an "article read" event that fires when a sentinel at the end of the article scrolls into view. With an empty body the sentinel was on screen at once, so the event could fire for an article nobody read.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  JSON-LD goes through the same marker
&lt;/h2&gt;

&lt;p&gt;JSON-LD &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; blocks had the same problem: a server-rendered string that the client never reads, shipped in both places. They now use the same marker, keyed by a hash of the JSON. One thing to watch: the client selector had to become &lt;code&gt;div[data-static-html]&lt;/code&gt;. With a bare &lt;code&gt;[data-static-html]:empty&lt;/code&gt;, the never-filled JSON-LD script matched as "still empty", so the beacon would never fire and the fallback would reload.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Page&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Longest case study&lt;/td&gt;
&lt;td&gt;512 KB&lt;/td&gt;
&lt;td&gt;262 KB (payload 42 KB)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Project list&lt;/td&gt;
&lt;td&gt;410 KB&lt;/td&gt;
&lt;td&gt;398 KB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That's 270 bodies across 87 pages, and all 3,047 JSON-LD blocks still parse.&lt;/p&gt;

&lt;h2&gt;
  
  
  When this is worth doing
&lt;/h2&gt;

&lt;p&gt;Only when a server component renders a large string that no client code reads: markdown bodies, CMS HTML, JSON-LD. If a client component needs the data as props, it has to be in the payload. For a blog or a docs site where the body is static HTML, the payload copy is pure overhead, and it grows with every article.&lt;/p&gt;

&lt;p&gt;If you'd rather not run a post-build step, check the payload first: in an App Router page, any big string you pass to &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt; ships twice. For the other things that made my list page heavy (repeated SVG paths, copied JSON-LD, class strings), see &lt;a href="https://www.mohamedgado.com/writing/nextjs-page-weight-rsc-payload" rel="noopener noreferrer"&gt;Cutting a Next.js page from 854 KB to 459 KB&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>performance</category>
    </item>
    <item>
      <title>Why GitHub shows a red X on commits whose deploys succeeded: cancel-in-progress</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Thu, 26 Nov 2026 17:02:42 +0000</pubDate>
      <link>https://dev.to/mohamedgado/why-github-shows-a-red-x-on-commits-whose-deploys-succeeded-cancel-in-progress-9c2</link>
      <guid>https://dev.to/mohamedgado/why-github-shows-a-red-x-on-commits-whose-deploys-succeeded-cancel-in-progress-9c2</guid>
      <description>&lt;p&gt;A GitHub Actions run cancelled by &lt;code&gt;concurrency: cancel-in-progress: true&lt;/code&gt; puts a red X on its commit, the same mark a failed run gets. For three days most commits on my site's &lt;code&gt;main&lt;/code&gt; branch showed that X, and none of the deploys had failed. Every Cloudflare build in that window succeeded (30 of 30). The X came from deploy runs that were "cancelled after 1s". The fix was to keep the debounce and stop cancelling runs: a run that has been superseded exits with code 0 and shows green.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does a cancelled GitHub Actions run count as a failure?
&lt;/h2&gt;

&lt;p&gt;On the commit, yes. The checks icon next to a commit in the commit list rolls every check run for that SHA into one mark. A &lt;code&gt;cancelled&lt;/code&gt; conclusion is not &lt;code&gt;success&lt;/code&gt;, so the roll-up is a red X, and from the commit list you can't tell it apart from a broken build. You have to open the run to see the word "cancelled".&lt;/p&gt;

&lt;p&gt;That matters if anyone reads the commit list as a health signal, and I do. A wall of red X's on a site that was deploying fine is noise that hides a real failure the day one happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow that produced it
&lt;/h2&gt;

&lt;p&gt;My site deploys through one GitHub Actions workflow that calls a Cloudflare Workers Builds deploy hook. I push in bursts (five commits in ten minutes is normal), and I didn't want five builds. So the workflow waited three minutes and relied on &lt;code&gt;concurrency&lt;/code&gt; to drop the waiting runs when a newer push arrived:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;concurrency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;production&lt;/span&gt;
  &lt;span class="na"&gt;cancel-in-progress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;DEBOUNCE_SECONDS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;180&lt;/span&gt;
      &lt;span class="na"&gt;HOOK&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.CF_DEPLOY_HOOK }}&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Wait for the push burst to settle&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sleep "$DEBOUNCE_SECONDS"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Trigger the Cloudflare Workers Builds deploy hook for main&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;curl -fsS -X POST "$HOOK"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The debounce worked: a burst became one deploy. But every commit in the burst except the last one got a cancelled run, and with it a red X.&lt;/p&gt;

&lt;p&gt;A habit made it worse. To skip the three-minute wait, sessions ran &lt;code&gt;gh workflow run deploy.yml&lt;/code&gt; right after a push. The dispatched run joined the same concurrency group and cancelled the push run in the same second. The dispatch run deployed fine, but it doesn't show on the commit, so the only check left on the commit was the cancelled one.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I traced it
&lt;/h2&gt;

&lt;p&gt;I checked the layers in order, from the symptom toward the deploy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Actions run conclusions&lt;/strong&gt; for the deploy workflow: no &lt;code&gt;failure&lt;/code&gt; at all, only &lt;code&gt;cancelled&lt;/code&gt; and &lt;code&gt;success&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloudflare's builds API&lt;/strong&gt;: every build in the window succeeded.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pairing timestamps&lt;/strong&gt;: each cancelled push run had a &lt;code&gt;workflow_dispatch&lt;/code&gt; run that started in the same second, or a newer push run.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So the red X's didn't come from any failure. The workflow's own design created them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: debounce without cancelling
&lt;/h2&gt;

&lt;p&gt;The run still waits, but it no longer depends on being cancelled. After the wait it asks GitHub which commit &lt;code&gt;main&lt;/code&gt; points at. If that is not its own commit, a newer push has arrived and that push's run will deploy, so this run exits 0:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;timeout-minutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
    &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;DEBOUNCE_SECONDS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ github.event_name == 'workflow_dispatch' &amp;amp;&amp;amp; 0 || 180 }}&lt;/span&gt;
      &lt;span class="na"&gt;HOOK&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.CF_DEPLOY_HOOK }}&lt;/span&gt;
      &lt;span class="na"&gt;GH_TOKEN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ github.token }}&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Wait for the push burst to settle&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sleep "$DEBOUNCE_SECONDS"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Trigger the Cloudflare Workers Builds deploy hook for main&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;if [ "$GITHUB_EVENT_NAME" = "push" ]; then&lt;/span&gt;
            &lt;span class="s"&gt;HEAD=$(gh api "repos/$GITHUB_REPOSITORY/commits/main" --jq .sha)&lt;/span&gt;
            &lt;span class="s"&gt;if [ "$HEAD" != "$GITHUB_SHA" ]; then&lt;/span&gt;
              &lt;span class="na"&gt;echo "::notice::Superseded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;main is at ${HEAD:0:7}, its own run deploys it."&lt;/span&gt;
              &lt;span class="s"&gt;exit 0&lt;/span&gt;
            &lt;span class="s"&gt;fi&lt;/span&gt;
          &lt;span class="s"&gt;fi&lt;/span&gt;
          &lt;span class="s"&gt;curl -fsS -X POST "$HOOK"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;concurrency&lt;/code&gt; block is gone. Three things changed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A superseded run is green.&lt;/strong&gt; It ends with a notice that names the newer commit, so the run log still explains why it didn't deploy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Only the head deploys.&lt;/strong&gt; Only one SHA can be the head of &lt;code&gt;main&lt;/code&gt;, so a burst still collapses into one deploy: the run for the last push.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A manual dispatch skips the wait.&lt;/strong&gt; &lt;code&gt;DEBOUNCE_SECONDS&lt;/code&gt; is 0 for &lt;code&gt;workflow_dispatch&lt;/code&gt;, so nobody has a reason to dispatch right after a push. After a push, you wait about four minutes and the push run deploys.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;gh&lt;/code&gt; is preinstalled on GitHub-hosted runners and reads &lt;code&gt;GH_TOKEN&lt;/code&gt;, and the default &lt;code&gt;github.token&lt;/code&gt; with &lt;code&gt;contents: read&lt;/code&gt; can read the commit. No extra secret is needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost
&lt;/h2&gt;

&lt;p&gt;The wait is billed Actions time. On a private repo that is about four minutes per push, out of the 2,000 free minutes a month. &lt;code&gt;cancel-in-progress&lt;/code&gt; hid that cost because cancelled runs stop early. If minutes get tight, lower &lt;code&gt;DEBOUNCE_SECONDS&lt;/code&gt;. You get less collapsing, and the commits stay green.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pin it with a test
&lt;/h2&gt;

&lt;p&gt;A workflow file is easy to "simplify" back into the old shape, because &lt;code&gt;cancel-in-progress&lt;/code&gt; looks like the obvious tool for this. A test that reads the YAML keeps it from coming back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'bursts become one deploy without cancelling: a superseded run exits green'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;doesNotMatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;cancel&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;\&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;commits&lt;/span&gt;\&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="s2"&gt;"\$HEAD"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"\$GITHUB_SHA"&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;\&lt;span class="n"&gt;s&lt;/span&gt;\&lt;span class="no"&gt;S&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;exit&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'a manual dispatch deploys at once, so nobody dispatches to skip the wait'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;event_name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'workflow_dispatch'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; \&lt;span class="o"&gt;|&lt;/span&gt;\&lt;span class="o"&gt;|&lt;/span&gt; \&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;+/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When cancel-in-progress is still right
&lt;/h2&gt;

&lt;p&gt;For pull request checks, &lt;code&gt;cancel-in-progress&lt;/code&gt; is a good default: nobody cares about a cancelled lint run on a commit that a newer push replaced, and it saves minutes. The trouble starts on a branch where people read the commit list as a deploy log. There, a cancelled run looks like a failed one, and a debounce that exits 0 gives you the same single deploy with a commit list that stays green.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A cancelled run shows as a red X on its commit. If commit checks are your health signal, don't let runs be cancelled routinely.&lt;/li&gt;
&lt;li&gt;Debounce by waiting and then checking whether your commit is still the head of the branch, not by cancelling.&lt;/li&gt;
&lt;li&gt;Before you chase a red X, open the run. "Cancelled after 1s" means a concurrency group cancelled it, not that a build broke.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>githubactions</category>
      <category>cicd</category>
      <category>devops</category>
    </item>
    <item>
      <title>A Cloudflare Worker route on a subdomain does nothing without a DNS record</title>
      <dc:creator>Mohamed Gado</dc:creator>
      <pubDate>Thu, 26 Nov 2026 17:02:07 +0000</pubDate>
      <link>https://dev.to/mohamedgado/a-cloudflare-worker-route-on-a-subdomain-does-nothing-without-a-dns-record-2kn6</link>
      <guid>https://dev.to/mohamedgado/a-cloudflare-worker-route-on-a-subdomain-does-nothing-without-a-dns-record-2kn6</guid>
      <description>&lt;p&gt;A Cloudflare Worker route like &lt;code&gt;app.example.com/*&lt;/code&gt; only runs when a request for that hostname reaches Cloudflare. For that, the hostname needs a DNS record in the zone, and the record has to be proxied (the orange cloud). Without one the name doesn't resolve at all, and &lt;code&gt;wrangler deploy&lt;/code&gt; still succeeds without a warning. When the Worker is the whole site and there is no origin server, the record to add is a proxied &lt;code&gt;AAAA&lt;/code&gt; pointing at &lt;code&gt;100::&lt;/code&gt;. I shipped a subdomain that sat in this state for part of a day, so I made the deploy tooling check that every Worker host has its record.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why doesn't my Worker route work on a subdomain?
&lt;/h2&gt;

&lt;p&gt;A route tells Cloudflare which Worker should handle requests that already reached Cloudflare for a given hostname and path. It doesn't publish the hostname. DNS does that. For a subdomain with no record, a browser's lookup gets NXDOMAIN (Chrome shows &lt;code&gt;DNS_PROBE_FINISHED_NXDOMAIN&lt;/code&gt;), the request never reaches Cloudflare, and the route never gets a chance to match.&lt;/p&gt;

&lt;p&gt;The record also has to be proxied. A DNS-only (grey cloud) record sends visitors straight to whatever IP it holds, past Cloudflare's network, so the Worker never sees them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened
&lt;/h2&gt;

&lt;p&gt;My site runs on one Worker with a route per hostname in &lt;code&gt;wrangler.jsonc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json-doc"&gt;&lt;code&gt;&lt;span class="nl"&gt;"routes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"www.mohamedgado.com/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"zone_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"mohamedgado.com"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"mohamedgado.com/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"zone_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"mohamedgado.com"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"masareef.mohamedgado.com/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"zone_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"mohamedgado.com"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"rafiq.mohamedgado.com/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"zone_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"mohamedgado.com"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"nafis.mohamedgado.com/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"zone_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"mohamedgado.com"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"pattern"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"hadeed.mohamedgado.com/*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"zone_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"mohamedgado.com"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each app gets a short install host (&lt;code&gt;hadeed.mohamedgado.com&lt;/code&gt;) that the Worker redirects to the right store. When a new iPhone app went live, a commit added its route, its zone rules, the production check and the sitemap entry. It deployed green. The name never resolved.&lt;/p&gt;

&lt;p&gt;Two things made it slip through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The checklist was stale.&lt;/strong&gt; The written rule for a new subdomain said "add one CNAME at the registrar". That was true until the zone's DNS moved to Cloudflare a few days earlier. After the move, nothing in the repo created the record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Another app already linked to it.&lt;/strong&gt; A "More from us" row in one of my other apps pointed at the new host, so real users could tap a link that went nowhere.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The fix: a proxied AAAA 100:: record
&lt;/h2&gt;

&lt;p&gt;Cloudflare's docs for Workers routes cover the case where the Worker is the origin: add a proxied &lt;code&gt;AAAA&lt;/code&gt; record with the content &lt;code&gt;100::&lt;/code&gt;. &lt;code&gt;100::&lt;/code&gt; is the IPv6 discard prefix. It's never routed anywhere, so if the proxy were ever turned off, the name would point at nothing instead of at somebody else's server. With the proxy on, Cloudflare answers the request and the route sends it to the Worker.&lt;/p&gt;

&lt;p&gt;One record per host, either in the dashboard or with the API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;WORKER_PLACEHOLDER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'AAAA'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'100::'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proxied&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'[portfolio] Worker route origin placeholder (Vercel retired)'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;cf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`/zones/${zoneId}/dns_records`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;WORKER_PLACEHOLDER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ttl: 1&lt;/code&gt; means "automatic", which is the only TTL a proxied record uses anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  Routes or Custom Domains?
&lt;/h2&gt;

&lt;p&gt;Workers also has Custom Domains. Those create the DNS record and the certificate for you, and they're the simpler choice when a Worker owns a whole hostname. Routes are what you use when one Worker answers several hostnames by pattern, or shares a hostname with other things. Routes leave DNS to you. If you use routes, the DNS record is your job, and nothing in the deploy will remind you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the tooling check it
&lt;/h2&gt;

&lt;p&gt;The real fix wasn't the one record. It was making a missing record impossible to ship again. My zone setup script, &lt;code&gt;pnpm cf:zone --production&lt;/code&gt;, already applied cache and redirect rules through the Cloudflare API. It now also walks every host the Worker answers and decides what that host's DNS needs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** Production hosts the Worker answers through its routes; each needs a proxied DNS record to exist. */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;WORKER_HOSTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;HOSTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;production&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;HOSTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;production&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * What a Worker host's DNS records need: 'ok', 'create' (none yet), 'proxy' (our placeholder,
 * orange cloud off) or 'conflict' (something else lives there; never overwritten, a human decides).
 */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;workerHostAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'create'&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'AAAA'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'100::'&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;ours&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'conflict'&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;proxied&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'proxy'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script creates a missing placeholder and turns the proxy back on for one that has it off. It never touches a host that holds anything else: a leftover CNAME to an old host could be a real service, so the script prints &lt;code&gt;CONFLICT, left alone&lt;/code&gt; and exits non-zero. A dry run prints &lt;code&gt;would create&lt;/code&gt; without changing anything.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WORKER_HOSTS&lt;/code&gt; is built from the same host map the routes and the redirects come from, so a new app can't get a route without getting a DNS row. A test checks that, and checks each decision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'every Worker host gets a proxied AAAA 100:: placeholder; a missing one is created, a foreign one is never overwritten'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="no"&gt;WORKER_HOSTS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workerHostAction&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'./zone-rules.mjs'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;HOSTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;production&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;WORKER_HOSTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`${app} has no placeholder row`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;WORKER_HOSTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;HOSTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;production&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;workerHostAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'create'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;workerHostAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'AAAA'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'100::'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proxied&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;workerHostAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'AAAA'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'100::'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proxied&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'proxy'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;workerHostAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'CNAME'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cname.vercel-dns.com'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proxied&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'conflict'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The dry run found more than DNS
&lt;/h2&gt;

&lt;p&gt;The first dry run against the live zone showed three problems at once: the missing record, the new host's zone rules that had never been applied, and three zone settings that had drifted back to Cloudflare's defaults (&lt;code&gt;early_hints&lt;/code&gt;, fonts and &lt;code&gt;automatic_https_rewrites&lt;/code&gt; were "on" again). I almost dismissed the drift as default noise. &lt;code&gt;early_hints&lt;/code&gt; is off on purpose on this zone, so the repo's value wins and the script set it back.&lt;/p&gt;

&lt;h2&gt;
  
  
  A subdomain is done when it answers
&lt;/h2&gt;

&lt;p&gt;The rule I wrote down after this: a new Worker subdomain is done when &lt;code&gt;pnpm cf:zone --production&lt;/code&gt; prints its host as &lt;code&gt;ok&lt;/code&gt; and the production check (&lt;code&gt;pnpm check:prod&lt;/code&gt;), which requests every app host and follows its redirect, is green. A merged commit doesn't count, and neither does a green deploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Worker route doesn't create DNS. Each hostname needs a proxied record, or the name doesn't resolve and the route never runs.&lt;/li&gt;
&lt;li&gt;When the Worker is the origin, use a proxied &lt;code&gt;AAAA 100::&lt;/code&gt;. It points nowhere if the proxy is ever turned off.&lt;/li&gt;
&lt;li&gt;Derive the DNS check from the same list as the routes, and let the script create the record instead of a checklist.&lt;/li&gt;
&lt;li&gt;Never let automation overwrite a record it didn't create. Report the conflict and fail.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloudflare</category>
      <category>workers</category>
      <category>dns</category>
    </item>
  </channel>
</rss>
