<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mohamed Gado on Medium]]></title>
        <description><![CDATA[Stories by Mohamed Gado on Medium]]></description>
        <link>https://medium.com/@boogado66?source=rss-64ca877889d3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*myORgiEwa4UQxd8VrIb4Aw.png</url>
            <title>Stories by Mohamed Gado on Medium</title>
            <link>https://medium.com/@boogado66?source=rss-64ca877889d3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:28:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@boogado66/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Arabic paragraphs in Markdown render left to right: a rehype plugin fix]]></title>
            <link>https://medium.com/@boogado66/arabic-paragraphs-in-markdown-render-left-to-right-a-rehype-plugin-fix-fd42440a487e?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd42440a487e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[markdown]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Sun, 29 Nov 2026 08:21:24 GMT</pubDate>
            <atom:updated>2026-11-29T08:21:24.984Z</atom:updated>
            <content:encoded><![CDATA[<p>Markdown has no syntax for text direction, so an Arabic paragraph inside an English page inherits dir=&quot;ltr&quot; unless the renderer adds a direction. On my site I fixed it with a small rehype plugin that sets dir=&quot;rtl&quot; 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.</p><p>My app pages are written in English and carry lists of Arabic links. Each Arabic run already had lang=&quot;ar&quot;, 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.</p><h3>Why not dir=”auto”?</h3><p>dir=&quot;auto&quot; 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.</p><h3>Why not count letters?</h3><p>Counting was my first attempt: more Arabic letters than Latin means right to left. An existing test failed on this line:</p><pre>Masareef (مصاريف) is an app. [تحميل مصاريف بالعربي](/x)</pre><p>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.</p><h3>The plugin</h3><pre>function rehypeArabicBlocks() {<br>  return (tree: HastRoot) =&gt; {<br>    visit(tree, &#39;element&#39;, (node: Element) =&gt; {<br>      if (!/^(p|li|h[2-6])$/.test(node.tagName)) return<br>      let text = &#39;&#39;<br>      visit(node, &#39;text&#39;, (t: { value: string }) =&gt; {<br>        text += t.value<br>      })<br>      const arabic = text.match(/\p{Script=Arabic}/gu)?.length ?? 0<br>      const latin = text.match(/\p{Script=Latin}/gu)?.length ?? 0<br>      const first = text.match(/\p{L}/u)?.[0] ?? &#39;&#39;<br>      if (arabic &lt;= latin || !/\p{Script=Arabic}/u.test(first)) return<br>      node.properties = {<br>        ...node.properties,<br>        dir: &#39;rtl&#39;,<br>        style: &#39;text-align:right&#39;,<br>      }<br>    })<br>  }<br>}</pre><p>It runs after remark-rehype, so it sees the final HTML elements. \p{Script=...} needs the u flag.</p><h3>The test</h3><p>Keep both cases in one test, so a later change can’t fix one and break the other:</p><pre>const { html } = await renderMarkdown(&#39;بالعربية: [محفظة الذهب](/x)\n\nHadeed (حديد) is a workout planner.&#39;)<br>assert.match(html, /&lt;p dir=&quot;rtl&quot; style=&quot;text-align:right&quot;&gt;&lt;span lang=&quot;ar&quot;&gt;بالعربية/)<br>assert.match(html, /&lt;p&gt;Hadeed/)</pre><p>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.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd42440a487e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AbortError: signal is aborted without reason, and why my error tracker saw it]]></title>
            <link>https://medium.com/@boogado66/aborterror-signal-is-aborted-without-reason-and-why-my-error-tracker-saw-it-83879b295a66?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/83879b295a66</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Sat, 28 Nov 2026 17:20:52 GMT</pubDate>
            <atom:updated>2026-11-28T17:20:52.679Z</atom:updated>
            <content:encoded><![CDATA[<p>AbortError: signal is aborted without reason is the message Chrome and Edge give the error an AbortController creates when you call controller.abort() with no argument. Firefox and Safari give the same error a different text: The operation was aborted. On my <a href="https://www.mohamedgado.com/projects/social-media-downloader">Social Downloader</a> 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 fetch had no catch. Passing abort() a reason, and filtering on the error&#39;s name rather than its text, fixes both halves.</p><h3>What does “signal is aborted without reason” mean?</h3><p>abort() takes an optional reason. When you leave it out, the signal makes one for you: a DOMException named AbortError. Every fetch using that signal rejects with that exception.</p><pre>const controller = new AbortController()<br>controller.abort()<br> <br>console.log(controller.signal.reason.name)    // &quot;AbortError&quot;<br>console.log(controller.signal.reason.message) // Chrome: &quot;signal is aborted without reason&quot;<br>                                              // Firefox, Safari: &quot;The operation was aborted.&quot;</pre><p>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).</p><h3>Where mine came from: a timeout with no reason</h3><p>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):</p><pre>async function resolveInBrowser(url) {<br>  const controller = new AbortController()<br>  const timer = setTimeout(() =&gt; controller.abort(), 6000)<br>  try {<br>    const response = await fetch(endpoint(url), { signal: controller.signal })<br>    if (!response.ok) return null<br>    return parse(await response.json())<br>  } catch {<br>    return null // timeout, offline, blocked: let the server answer<br>  } finally {<br>    clearTimeout(timer)<br>  }<br>}</pre><p>The fetch and the .json() both sit inside the try, and the catch turns a timeout into null. 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 AbortError: signal is aborted without reason, marked as unhandled.</p><h3>Why a caught AbortError can still show as unhandled</h3><p>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 controller.abort() inside the timer, which says less than it seems to. A DOMException records its stack when it is created, and abort() 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.</p><p>My promise was handled, so the unhandled one had to be someone else’s. Any script that patches window.fetch to watch requests can make a second promise from the original:</p><pre>const originalFetch = window.fetch<br>window.fetch = function (...args) {<br>  const request = originalFetch.apply(this, args)<br>  request.then((response) =&gt; record(response)) // a second promise, never caught<br>  return request<br>}</pre><p>The page gets request back and catches it. The .then() the wrapper made is a separate promise, and it rejects with the same AbortError. Nothing catches that one, so the browser fires unhandledrejection, and an error tracker listening for it reports the cancel as a crash. Browser extensions, analytics snippets and ad scripts all patch fetch 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.</p><h3>How to tell if the error is yours</h3><ol><li>Check how it was captured. An error tracker that marks it handled: false caught it from unhandledrejection or window.onerror, not from your own catch.</li><li>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 User-Agent, or you will get a challenge page instead of JavaScript.</li><li>If the frame is an abort() call, read every promise that uses that signal. When each one is awaited inside a try, or has a .catch(), the unhandled copy is not yours.</li><li>Read the session around it. Mine showed resolve_failed 4 ms before the exception: the cancel was the timeout doing its job.</li></ol><h3>How to fix it</h3><p>Give abort() a reason, and the rejection says what happened in every browser:</p><pre>setTimeout(() =&gt; controller.abort(new DOMException(&#39;tikwm timed out&#39;, &#39;TimeoutError&#39;)), 6000)<br> <br>// or let the platform do it:<br>fetch(url, { signal: AbortSignal.timeout(6000) }) // rejects with a TimeoutError</pre><p>If you switch to TimeoutError, check every catch that tests error.name === &#39;AbortError&#39;. A timeout no longer matches it, so code that treats a cancel as &quot;the user changed their mind&quot; will now treat a timeout as a failure. That is usually what you want, but check it on purpose.</p><p>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, The operation was aborted. Chrome&#39;s wording went straight through. A pattern for one engine&#39;s message misses the others, so match them together:</p><pre>const BARE_ABORT = /^(DOMException: )?AbortError: (The operation was aborted|signal is aborted without reason)\.?$/i</pre><p>If your tracker gives you the exception type as a separate field, filter on AbortError there and skip the text entirely.</p><p>I also wrote about the same class of noise from injected scripts in <a href="https://www.mohamedgado.com/writing/gcrweb-firefox-injected-script-errors">__gCrWeb and </a><a href="https://www.mohamedgado.com/writing/gcrweb-firefox-injected-script-errors">__firefox__ errors</a>: code that isn&#39;t yours, reported as if it were.</p><h3>FAQ</h3><h3>Is “signal is aborted without reason” a network error?</h3><p>No. The request was cancelled by code in the page calling abort(). A network failure shows up as TypeError: Failed to fetch in Chrome, not as an AbortError.</p><h3>Why does Firefox say “The operation was aborted” instead?</h3><p>The error is the same, a DOMException named AbortError. Each engine picks its own message text. Code that checks the name works everywhere, and code that checks the message works in one browser.</p><h3>Should I report AbortError to my error tracker at all?</h3><p>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.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83879b295a66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[expo-screen-capture and READ_MEDIA_IMAGES: the Play fix that crashed Android 14]]></title>
            <link>https://medium.com/@boogado66/expo-screen-capture-and-read-media-images-the-play-fix-that-crashed-android-14-ac676a2f2b7f?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac676a2f2b7f</guid>
            <category><![CDATA[export]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google-play]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Fri, 27 Nov 2026 17:47:56 GMT</pubDate>
            <atom:updated>2026-11-27T17:47:56.143Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.mohamedgado.com/projects/nafis">Nafis</a>, 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 expo-screen-capture. 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&#39;s the chain, and how to block expo-screen-capture&#39;s permissions without the crash.</p><h3>Play rejects READ_MEDIA_IMAGES</h3><p>The rejection said:</p><blockquote><em>All developers requesting access to the photo and video permissions are required to tell Google Play about the core functionality of their app.</em></blockquote><p>Nafis doesn’t read photos. The permission came from expo-screen-capture, which declares READ_MEDIA_IMAGES for its screenshot listener (addScreenshotListener). On Android 13 and below, it detects a screenshot by watching the media store for new images. Nafis only calls preventScreenCaptureAsync(), which sets FLAG_SECURE on the window and needs no permission at all:</p><pre>useEffect(() =&gt; {<br>  if (secureScreen) void preventScreenCaptureAsync().catch(() =&gt; {})<br>  else void allowScreenCaptureAsync().catch(() =&gt; {})<br>}, [secureScreen])</pre><p>So I added the library’s permissions to blockedPermissions in app.json: READ_MEDIA_IMAGES, and also DETECT_SCREEN_CAPTURE, the Android 14 half of the same listener. The upload was accepted.</p><h3>Checking the manifest: read the AAB, not the installed app</h3><p>Before resubmitting, I wanted to confirm the permission was gone. adb shell dumpsys package on the installed app didn&#39;t list READ_MEDIA_IMAGES, but it didn&#39;t list it for the old build either. The library declares it with maxSdkVersion=&quot;33&quot;, so on a newer phone the package manager drops it at install time.</p><p>Play reads the bundle, so check the bundle. Unzip the .aab and read base/manifest/AndroidManifest.xml. In a bundle it&#39;s a protobuf file, so use bundletool, or aapt2 dump xmltree on the APK it produces. That&#39;s the manifest Play&#39;s review sees.</p><h3>Every Android 14 launch crashes</h3><p>The release built, uploaded and shipped. It also crashed on open for every user on Android 14 or newer. Logcat:</p><pre>FATAL EXCEPTION: expo-updates-error-recovery<br>java.lang.SecurityException: Permission Denial: registerScreenCaptureObserver<br>  requires android.permission.DETECT_SCREEN_CAPTURE<br>    at android.app.Activity.registerScreenCaptureCallback(Activity.java:10037)</pre><p>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:</p><pre>OnCreate {<br>  if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {<br>    screenCaptureCallback = Activity.ScreenCaptureCallback { emitEvent() }<br>    registerCallback() // calls Activity.registerScreenCaptureCallback<br>  } else {<br>    screenshotEventEmitter = ScreenshotEventEmitter(context) { emitEvent() }<br>  }<br>}<br> <br>OnActivityEntersForeground {<br>  registerCallback()<br>  screenshotEventEmitter?.onHostResume()<br>}</pre><p>registerScreenCaptureCallback needs DETECT_SCREEN_CAPTURE. With that permission blocked, Android throws a SecurityException, 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&#39;s why the crash hit Android 14+ only.</p><p>My first suspect was something else in the same commit, an Updates.reloadAsync() call, because the exception&#39;s thread was named expo-updates-error-recovery. The stack trace named the real cause in one line, once I reproduced the crash with a release build on an emulator.</p><h3>The fix: block one permission, keep the other</h3><p>DETECT_SCREEN_CAPTURE is a normal permission, granted at install without a prompt, and Play doesn&#39;t ask about it. Only READ_MEDIA_IMAGES triggers the photo-and-video declaration. So the fix was to unblock one line:</p><pre>&quot;android&quot;: {<br>  &quot;blockedPermissions&quot;: [<br>    &quot;android.permission.READ_MEDIA_IMAGES&quot;<br>  ]<br>}</pre><p>With READ_MEDIA_IMAGES blocked, the Android 13-and-below listener fails quietly, and the app never uses it anyway. With DETECT_SCREEN_CAPTURE declared, the Android 14 registration succeeds. preventScreenCaptureAsync() works on both, since FLAG_SECURE never needed either permission.</p><h3>The process gaps that let it ship</h3><ul><li><strong>No release build was launched before submitting.</strong> 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.</li><li><strong>Build and submit were one command.</strong> 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.</li><li><strong>Play Vitals looked clean after 7 hours.</strong> Crash reporting lags. An empty dashboard on release day doesn’t mean the release is fine.</li></ul><h3>Takeaways</h3><ul><li>blockedPermissions removes a permission your dependencies may use without asking you. Read where the library uses it before blocking it.</li><li>expo-screen-capture registers its Android 14 screenshot callback at startup, whether or not you add a listener. Keep DETECT_SCREEN_CAPTURE, and block only READ_MEDIA_IMAGES if Play asks.</li><li>Check permissions in the .aab manifest. An installed app&#39;s dumpsys hides permissions with a maxSdkVersion.</li><li>A crash that only hits some Android versions usually lines up with an SDK check in some library’s native code.</li><li>Launch the release build once before you submit it.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac676a2f2b7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter exact alarm permission on Android 14: stop the jump to Settings]]></title>
            <link>https://medium.com/@boogado66/flutter-exact-alarm-permission-on-android-14-stop-the-jump-to-settings-e073db2dc43d?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e073db2dc43d</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Fri, 27 Nov 2026 17:47:00 GMT</pubDate>
            <atom:updated>2026-11-27T17:47:00.526Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.mohamedgado.com/projects/hadeed">Hadeed</a>, 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 <strong>Alarms &amp; reminders</strong> settings page and threw me out of the app mid-set. The call behind it, requestExactAlarmsPermission() from flutter_local_notifications, had been there since the first commit. Fixing it uncovered a second bug underneath. Without that permission, an alarmClock schedule never rang at all.</p><h3>Why requestExactAlarmsPermission opens Settings</h3><p>Exact alarms are a special permission on Android 12 and later. There’s no runtime dialog for SCHEDULE_EXACT_ALARM. The only way to &quot;request&quot; 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&#39;t alarm clocks or calendars start with this permission denied.</p><p>flutter_local_notifications exposes this as requestExactAlarmsPermission(). 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.</p><p>The unit tests never caught it. They all mocked the plugin’s platform channel, so a call to requestExactAlarmsPermission just returned a value. Nothing checked what that call does on a device.</p><h3>Why USE_EXACT_ALARM wasn’t an option</h3><p>Android also has USE_EXACT_ALARM, 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 USE_EXACT_ALARM before the first closed test. That left SCHEDULE_EXACT_ALARM, which Play allows but the user must turn on, so for most users it&#39;s off.</p><h3>The second bug: alarmClock without the permission</h3><p>The rest alarm was scheduled with AndroidScheduleMode.alarmClock, which needs exact-alarm permission. Without it, zonedSchedule throws. My schedule() caught and logged errors, so nothing crashed. The alarm just never got scheduled.</p><p>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.</p><h3>The fix: check, then fall back to an inexact alarm</h3><p>Three changes:</p><ol><li><strong>Never call </strong><strong>requestExactAlarmsPermission() inside a flow.</strong> The permission request now asks for notification permission only.</li><li><strong>Check before scheduling.</strong> canScheduleExactNotifications() tells you whether exact alarms are allowed, without leaving the app.</li><li><strong>Pick the schedule mode from that answer.</strong> Use alarmClock when it&#39;s allowed, and inexactAllowWhileIdle when it isn&#39;t.</li></ol><pre>Future&lt;bool&gt; requestPermission() async {<br>  // No requestExactAlarmsPermission here: on Android 14 it opens system<br>  // Settings. schedule() falls back to an inexact alarm instead.<br>  return await android?.requestNotificationsPermission() ?? true;<br>}<br> <br>Future&lt;bool&gt; canExact() async {<br>  try {<br>    return await android?.canScheduleExactNotifications() ?? false;<br>  } catch (_) {<br>    return false;<br>  }<br>}<br> <br>AndroidScheduleMode restAlarmMode({required bool canExact}) =&gt;<br>    canExact ? AndroidScheduleMode.alarmClock : AndroidScheduleMode.inexactAllowWhileIdle;</pre><p>And in the schedule call:</p><pre>await plugin.zonedSchedule(<br>  id,<br>  title,<br>  body,<br>  when,<br>  details,<br>  androidScheduleMode: restAlarmMode(canExact: await canExact()),<br>);</pre><p>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.</p><p>Hadeed’s weekly training reminder already used this “exact if allowed, otherwise inexact” pattern. The rest alarm was the one place that didn’t.</p><h3>Test what must NOT be called</h3><p>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:</p><pre>test(&#39;asking for permission never opens system Settings&#39;, () async {<br>  await RestAlarm.instance.requestPermission();<br>  expect(sentMethods(), isNot(contains(&#39;requestExactAlarmsPermission&#39;)));<br>});<br> <br>test(&#39;without exact-alarm permission it still schedules, inexact&#39;, () async {<br>  exactAllowed = false;<br>  await RestAlarm.instance.schedule(const Duration(seconds: 90));<br>  expect(scheduledArgs()[&#39;scheduleMode&#39;], &#39;inexactAllowWhileIdle&#39;);<br>});</pre><p>Both failed against the old code and pass with the fix.</p><h3>Checklist for exact alarms in Flutter</h3><ul><li>Don’t call requestExactAlarmsPermission() from a flow the user is in the middle of. It opens a settings page, not a dialog.</li><li>Call canScheduleExactNotifications() before every schedule, and choose alarmClock or inexactAllowWhileIdle from the result.</li><li>Don’t declare USE_EXACT_ALARM unless your app really is an alarm clock or a calendar. Play checks.</li><li>Make sure a failed zonedSchedule is visible somewhere. A caught-and-logged error here means a silent alarm.</li><li>Run permission flows on a real Android 14 phone once. A mocked channel can’t show you a settings page.</li></ul><h3>Takeaways</h3><ul><li>On Android 14, exact-alarm permission starts denied for most apps, and asking for it means leaving your app.</li><li>alarmClock without that permission doesn&#39;t fall back by itself. It throws, and the alarm never rings.</li><li>Check, then degrade: exact when allowed, inexactAllowWhileIdle otherwise.</li><li>When a test mocks a platform call, also assert the calls that must never be made.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e073db2dc43d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[expo-audio stops playing in the background? Check who set the audio mode]]></title>
            <link>https://medium.com/@boogado66/expo-audio-stops-playing-in-the-background-check-who-set-the-audio-mode-0c1996137018?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c1996137018</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[export]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Fri, 27 Nov 2026 17:46:07 GMT</pubDate>
            <atom:updated>2026-11-27T17:46:07.769Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://www.mohamedgado.com/projects/rafiq">Rafiq</a>, 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 setAudioModeAsync with shouldPlayInBackground: false. In expo-audio that call isn&#39;t about one player. It sets the mode for the whole app, and it stays set until something sets it again.</p><h3>The symptom: every player pauses when the app goes to the background</h3><p>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 shouldPlayInBackground: true at startup. That&#39;s the part that made it confusing, since the setting was right when the app opened.</p><p>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.</p><h3>The cause: setAudioModeAsync is process-wide</h3><p>The adhan sound picker started each preview like this:</p><pre>// The picker&#39;s preview, before the fix<br>await setAudioModeAsync({<br>  playsInSilentMode: true,<br>  shouldPlayInBackground: false, // a 20 s preview shouldn&#39;t keep playing from a pocket<br>})<br>const player = createAudioPlayer(source)<br>player.play()</pre><p>The intent was reasonable. A 20-second preview of a muezzin shouldn’t keep playing after you put the phone away. But setAudioModeAsync doesn&#39;t configure that player. It configures the audio session for the whole process. On Android, expo-audio keeps a single shouldPlayInBackground 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&#39;s AudioModule.kt:</p><pre>AsyncFunction(&quot;setAudioModeAsync&quot;) { mode: AudioMode -&gt;<br>  shouldPlayInBackground = mode.shouldPlayInBackground<br>  // ...<br>}<br> <br>OnActivityEntersBackground {<br>  if (!shouldPlayInBackground) {<br>    allPlayables.forEach { playable -&gt;<br>      if (playable.isPlaying) { playable.isPaused = true; playable.pause() }<br>    }<br>  }<br>}</pre><p>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.</p><h3>Why it took longer than it should have</h3><ul><li><strong>“Since the last release” sent me to the wrong diff.</strong> 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.</li><li><strong>An earlier cleanup had missed this caller.</strong> A refactor had already moved three providers’ setAudioModeAsync 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.</li><li><strong>A comment made the bug look deliberate.</strong> 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.</li></ul><p>The same search turned up a second, quieter bug. When three providers each called setAudioModeAsync on mount, the last one to run won. React runs child effects before parent effects, so the outermost provider always wrote last. One provider&#39;s interruptionMode: &#39;mixWithOthers&#39; had never taken effect.</p><h3>The fix: one owner for the audio mode</h3><p>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.</p><pre>useEffect(() =&gt; {<br>  const sub = AppState.addEventListener(&#39;change&#39;, (state) =&gt; {<br>    if (state === &#39;background&#39;) stopPreview()<br>  })<br>  return () =&gt; sub.remove()<br>}, [stopPreview])</pre><p>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:</p><pre>export function useAudioSessionMode(keepPlaying: boolean) {<br>  useEffect(() =&gt; {<br>    const apply = () =&gt;<br>      setAudioModeAsync({<br>        playsInSilentMode: true,<br>        shouldPlayInBackground: keepPlaying,<br>        interruptionMode: &#39;doNotMix&#39;,<br>      }).catch(reportError)<br>    apply()<br>    const sub = AppState.addEventListener(&#39;change&#39;, (state) =&gt; {<br>      if (state === &#39;active&#39;) apply()<br>    })<br>    return () =&gt; sub.remove()<br>  }, [keepPlaying])<br>}</pre><p>keepPlaying combines the user&#39;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&#39;s one value, and one hook writes it.</p><p>A test pins the rule that this hook is the only caller of setAudioModeAsync. If a future screen adds its own call, the test fails, so the bug can&#39;t come back silently.</p><h3>How to check your own app</h3><p>If expo-audio playback stops when your app goes to the background:</p><ol><li>Search the whole repo for setAudioModeAsync, not just your audio folder. Any call with shouldPlayInBackground: false affects every player.</li><li>Check the config plugin. On iOS, background audio also needs the UIBackgroundModes audio entry, which the expo-audio plugin adds when you enable background playback.</li><li>Count the callers. With more than one, the last write wins, and effect order decides which one that is.</li><li>If a single sound must not play in the background, stop that sound yourself on an AppState background event. Leave the session alone.</li></ol><h3>Takeaways</h3><ul><li>setAudioModeAsync sets the mode for every player in the app, not for the one you&#39;re about to create.</li><li>Give a process-wide setting exactly one caller, and pin that with a test.</li><li>When a refactor’s goal is “one owner”, search the repo for the function name instead of the folders you expect it in.</li><li>Set state you can’t read back again on every return to the foreground.</li><li>A bug report that says “since the last release” tells you when someone noticed, not when the code changed.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c1996137018" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cross-posting to dev.to, Hashnode and Medium with a canonical URL]]></title>
            <link>https://medium.com/@boogado66/cross-posting-to-dev-to-hashnode-and-medium-with-a-canonical-url-abe0bdffe8ca?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/abe0bdffe8ca</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[blogging]]></category>
            <category><![CDATA[content-marketing]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 21:58:53 GMT</pubDate>
            <atom:updated>2026-11-26T21:58:53.751Z</atom:updated>
            <content:encoded><![CDATA[<p>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.</p><h3>What a canonical URL does on a cross-post</h3><p>A copy of an article on another domain is duplicate content. Search engines pick one version to rank. The canonical link (&lt;link rel=&quot;canonical&quot; href=&quot;...&quot;&gt; in the copy&#39;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.</p><p>Each platform sets that tag from a field in the post settings. If you skip the field, the copy points to itself.</p><h3>dev.to: the API, with two traps</h3><p>dev.to (Forem) has a real API. One POST creates a published post with the canonical set:</p><pre>export function devtoArticle(a) {<br>  return {<br>    title: a.title,<br>    body_markdown: a.body,<br>    published: true,<br>    canonical_url: a.url,<br>    description: a.description,<br>    tags: devtoTags(a.tags),<br>  }<br>}</pre><p>Two things bit me:</p><ul><li><strong>The RSS import makes drafts, sometimes without the canonical.</strong> 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.</li><li><strong>Front matter beats the API field.</strong> An imported draft’s body_markdown starts with front matter saying published: false. A PUT that sends published: true without a new body returns 200 and leaves the draft a draft. Send the body every time.</li></ul><p>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 Next.js becomes nextjs.</p><p>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.</p><h3>Hashnode: paste the Markdown, set the canonical by hand</h3><p>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 /writing/x in a copy would otherwise point at Hashnode.</p><p>In the post settings there are three fields to fill:</p><ul><li><strong>The canonical URL.</strong> It’s the “originally published” option in the article settings.</li><li><strong>The SEO title.</strong> I use the same short title as the site’s &lt;title&gt;.</li><li><strong>The SEO description.</strong> 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.</li></ul><p>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.</p><h3>Medium: paste HTML, because the importer drops code</h3><p>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:</p><pre>export async function plainHtml(markdown) {<br>  const file = await unified()<br>    .use(remarkParse)<br>    .use(remarkGfm)<br>    .use(remarkRehype)<br>    .use(tablesToLists)<br>    .use(rehypeStringify)<br>    .process(markdown)<br>  return String(file)<br>    // Medium splits a code block into separate boxes at every empty line.<br>    .replace(/&lt;pre&gt;[\s\S]*?&lt;\/pre&gt;/g, (pre) =&gt; pre.replace(/\n(?=\n)/g, &#39;\n &#39;))<br>    // The Windows HTML clipboard garbles raw UTF-8, so non-ASCII goes in as entities.<br>    .replace(/[^\x00-\x7f]/gu, (ch) =&gt; `&amp;#${ch.codePointAt(0)};`)<br>}</pre><ul><li><strong>Tables become lists.</strong> Medium has no tables, and pasted cells run together into one line. A small rehype plugin turns each row into a bullet like “<strong>RSC payload</strong> — 280 KB”.</li><li><strong>Empty lines inside code get a no-break space</strong>, so each code block stays one box.</li><li><strong>Non-ASCII becomes HTML entities</strong>, because the clipboard step mangles UTF-8.</li></ul><p>On Windows, Set-Clipboard -AsHtml 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 powershell.exe:</p><pre>powershell.exe -NoProfile -Command &quot;Set-Clipboard -AsHtml -Value (Get-Content -Raw &#39;article.html&#39;)&quot;</pre><p>Then type the title, press Enter and paste. Before publishing, I count the &lt;pre&gt; elements in the editor against the code blocks in the source.</p><p>Medium’s canonical setting is only in the story’s settings page after publishing: <strong>Advanced Settings → “This story was originally published elsewhere”</strong>, then <strong>Edit canonical link</strong>, paste the URL, <strong>Save canonical link</strong>. Topics allow 5 per story and 25 characters each. Commas don’t separate them; press Enter after each one.</p><h3>Check the canonical on the live copy</h3><p>A form that says “saved” isn’t proof. For each copy, I read the canonical from the published page:</p><ul><li><strong>dev.to and Hashnode:</strong> fetch the post URL and read link[rel=canonical].</li><li><strong>Medium:</strong> 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.</li></ul><pre>const html = await (await fetch(&#39;/p/&lt;post-id&gt;&#39;)).text()<br>new DOMParser().parseFromString(html, &#39;text/html&#39;).querySelector(&#39;link[rel=canonical]&#39;)?.getAttribute(&#39;href&#39;)</pre><p>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.</p><h3>Takeaways</h3><ul><li>Write once on your own domain, and give every copy a canonical link back to it.</li><li>dev.to: use the API, and send the body on every update, because its front matter beats the published field.</li><li>Hashnode on the free plan: paste Markdown with absolute links, and keep descriptions at 150 characters or less.</li><li>Medium: paste HTML, not the importer. Turn tables into lists, set the canonical after publishing, then read it back from the live page.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abe0bdffe8ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bing Webmaster API ThrottleUser and ThrottleIP: what each refusal means]]></title>
            <link>https://medium.com/@boogado66/bing-webmaster-api-throttleuser-and-throttleip-what-each-refusal-means-8fbd831d99e9?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fbd831d99e9</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[bing]]></category>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 21:57:17 GMT</pubDate>
            <atom:updated>2026-11-26T21:57:17.534Z</atom:updated>
            <content:encoded><![CDATA[<p>The Bing Webmaster API has two throttle errors that look alike and mean different things. ERROR!!! ThrottleIP is about where the call comes from: Bing refused every call my Cloudflare Worker made, while the same key worked from any other machine. ERROR!!! ThrottleUser is about the account and the call: on 26 November Bing answered my sitemap submit (SubmitFeed) with 400 ThrottleUser from Cloudflare&#39;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.</p><h3>What does ERROR!!! ThrottleIP mean?</h3><p>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 ThrottleIP. The same API key, from my laptop, worked on the first try.</p><p>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 (pnpm check:bing), and the Worker no longer calls Bing at all.</p><h3>What does ERROR!!! ThrottleUser mean?</h3><p>This one followed the account, not the network. The response body was:</p><pre>{&quot;ErrorCode&quot;:4,&quot;Message&quot;:&quot;ERROR!!! ThrottleUser&quot;}</pre><p>What I could pin down, all with the same key:</p><ul><li><strong>SubmitFeed (sitemap)</strong> — From: Cloudflare Workers Builds; Result: 400 ThrottleUser</li><li><strong>SubmitFeed (sitemap)</strong> — From: Home connection; Result: 400 ThrottleUser</li><li><strong>GetUrlSubmissionQuota</strong> — From: Home connection; Result: 200</li><li><strong>SubmitUrlBatch (3 URLs)</strong> — From: Home connection; Result: 200</li></ul><p>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.</p><h3>How the throttle broke my deploy</h3><p>Each deploy runs a script that tells search engines what changed:</p><ol><li>IndexNow gets the URLs whose content changed (Bing, Yandex, Seznam and Naver read it).</li><li>Google Search Console and Bing get the sitemap, but only when a URL or a lastmod moved.</li><li>A D1 table records each URL’s fingerprint and lastmod, so the next deploy can tell what moved.</li></ol><p>The script had one rule for step 2: if any engine refused the sitemap, keep the old lastmod values so the next deploy retries. That&#39;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 null lastmod. The next deploy saw the sitemap as changed again, pinged both engines again, and got the same refusal from Bing.</p><p>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 lastmod IS NULL found exactly the three newest pages.</p><h3>The fix: a throttle is a skip</h3><p>The outcome of a sitemap submit now has three values, and only a real refusal counts as a failure:</p><pre>/**<br> * Bing SubmitFeed result as &#39;ok&#39; | &#39;skipped&#39; | &#39;failed&#39;. A throttle is a skip: Bing re-reads a<br> * sitemap it already has, and IndexNow already carries the changed URLs.<br> */<br>export function bingFeedOutcome(status, text) {<br>  if (status &gt;= 200 &amp;&amp; status &lt; 300) return &#39;ok&#39;<br>  return status === 400 &amp;&amp; /ERROR!!! Throttle/.test(text) ? &#39;skipped&#39; : &#39;failed&#39;<br>}</pre><p>In the deploy script, a skip prints a notice instead of an error, and the lastmod values are saved:</p><pre>const text = await res.text().catch(() =&gt; &#39;&#39;)<br>const outcome = bingFeedOutcome(res.status, text)<br>if (outcome === &#39;skipped&#39;) console.log(`::notice::Bing sitemap throttled, already known to Bing: ${text.slice(0, 200)}`)<br>if (outcome !== &#39;failed&#39;) return outcome</pre><p>An invalid key or a 500 still fails and still holds the lastmod values back for a retry. The test pins both sides:</p><pre>test(&#39;bingFeedOutcome: 200 is ok, a Throttle* refusal is skipped, any other refusal fails&#39;, () =&gt; {<br>  assert.equal(bingFeedOutcome(200, &#39;{&quot;d&quot;:null}&#39;), &#39;ok&#39;)<br>  assert.equal(bingFeedOutcome(400, &#39;{&quot;ErrorCode&quot;:4,&quot;Message&quot;:&quot;ERROR!!! ThrottleUser&quot;}&#39;), &#39;skipped&#39;)<br>  assert.equal(bingFeedOutcome(400, &#39;{&quot;Message&quot;:&quot;ERROR!!! ThrottleIP&quot;}&#39;), &#39;skipped&#39;)<br>  assert.equal(bingFeedOutcome(400, &#39;{&quot;Message&quot;:&quot;ERROR!!! InvalidApiKey&quot;}&#39;), &#39;failed&#39;)<br>  assert.equal(bingFeedOutcome(500, &#39;Throttle in an HTML error page&#39;), &#39;failed&#39;)<br>})</pre><p>After the fix, one run saved the four pending rows, and the next dry run reported sitemap unchanged.</p><h3>Read Bing’s message, not just the status</h3><p>Bing returns 400 for a bad key, a throttle and a malformed request alike. The reason is in the body’s Message field. My API client puts it in every error it throws:</p><pre>function reason(text) {<br>  try {<br>    return String(JSON.parse(text)?.Message ?? text).slice(0, 200)<br>  } catch {<br>    return text.slice(0, 200)<br>  }<br>}</pre><p>An error that says bing GetCrawlStats 400 ERROR!!! ThrottleIP sends you to the right fix on the first read. A bare 400 would have me checking the key first.</p><h3>You may not need SubmitFeed on every deploy</h3><p>Bing gets new and changed URLs in two other ways:</p><ul><li><strong>IndexNow.</strong> Any change goes out at deploy time, and it doesn’t depend on the sitemap call.</li><li><strong>SubmitUrlBatch.</strong> It’s the Webmaster API’s own URL submit, with a quota of 10,000 a day on my site (GetUrlSubmissionQuota reports yours).</li></ul><p>Once Bing knows your sitemap, it re-reads it on its own schedule. Resubmitting it on every deploy mostly earns throttles.</p><h3>Takeaways</h3><ul><li>ThrottleIP is about where the call comes from. Shared egress such as Cloudflare Workers gets it, so call Bing from somewhere with its own IP.</li><li>ThrottleUser followed the account and the call (SubmitFeed), not the IP or the key. Other calls kept working.</li><li>If a failed submit holds back state for a retry, a throttle must not count as a failure, or the retry repeats forever.</li><li>Check the stored state after the first deploy that adds pages. A null lastmod was the only sign of this one.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fbd831d99e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Cloudflare Worker route on a subdomain does nothing without a DNS record]]></title>
            <link>https://medium.com/@boogado66/a-cloudflare-worker-route-on-a-subdomain-does-nothing-without-a-dns-record-8120180fd130?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8120180fd130</guid>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloudflare-workers]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 17:20:04 GMT</pubDate>
            <atom:updated>2026-11-26T17:20:04.979Z</atom:updated>
            <content:encoded><![CDATA[<p>A Cloudflare Worker route like app.example.com/* 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&#39;t resolve at all, and wrangler deploy 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 AAAA pointing at 100::. 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.</p><h3>Why doesn’t my Worker route work on a subdomain?</h3><p>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 DNS_PROBE_FINISHED_NXDOMAIN), the request never reaches Cloudflare, and the route never gets a chance to match.</p><p>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.</p><h3>What happened</h3><p>My site runs on one Worker with a route per hostname in wrangler.jsonc:</p><pre>&quot;routes&quot;: [<br>  { &quot;pattern&quot;: &quot;www.mohamedgado.com/*&quot;, &quot;zone_name&quot;: &quot;mohamedgado.com&quot; },<br>  { &quot;pattern&quot;: &quot;mohamedgado.com/*&quot;, &quot;zone_name&quot;: &quot;mohamedgado.com&quot; },<br>  { &quot;pattern&quot;: &quot;masareef.mohamedgado.com/*&quot;, &quot;zone_name&quot;: &quot;mohamedgado.com&quot; },<br>  { &quot;pattern&quot;: &quot;rafiq.mohamedgado.com/*&quot;, &quot;zone_name&quot;: &quot;mohamedgado.com&quot; },<br>  { &quot;pattern&quot;: &quot;nafis.mohamedgado.com/*&quot;, &quot;zone_name&quot;: &quot;mohamedgado.com&quot; },<br>  { &quot;pattern&quot;: &quot;hadeed.mohamedgado.com/*&quot;, &quot;zone_name&quot;: &quot;mohamedgado.com&quot; }<br>]</pre><p>Each app gets a short install host (hadeed.mohamedgado.com) 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.</p><p>Two things made it slip through:</p><ul><li><strong>The checklist was stale.</strong> 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.</li><li><strong>Another app already linked to it.</strong> 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.</li></ul><h3>The fix: a proxied AAAA 100:: record</h3><p>Cloudflare’s docs for Workers routes cover the case where the Worker is the origin: add a proxied AAAA record with the content 100::. 100:: is the IPv6 discard prefix. It&#39;s never routed anywhere, so if the proxy were ever turned off, the name would point at nothing instead of at somebody else&#39;s server. With the proxy on, Cloudflare answers the request and the route sends it to the Worker.</p><p>One record per host, either in the dashboard or with the API:</p><pre>export const WORKER_PLACEHOLDER = { type: &#39;AAAA&#39;, content: &#39;100::&#39;, proxied: true, comment: &#39;[portfolio] Worker route origin placeholder (Vercel retired)&#39; }<br> <br>await cf(`/zones/${zoneId}/dns_records`, {<br>  method: &#39;POST&#39;,<br>  body: JSON.stringify({ ...WORKER_PLACEHOLDER, name: host, ttl: 1 }),<br>})</pre><p>ttl: 1 means &quot;automatic&quot;, which is the only TTL a proxied record uses anyway.</p><h3>Routes or Custom Domains?</h3><p>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.</p><h3>Make the tooling check it</h3><p>The real fix wasn’t the one record. It was making a missing record impossible to ship again. My zone setup script, pnpm cf:zone --production, already applied cache and redirect rules through the Cloudflare API. It now also walks every host the Worker answers and decides what that host&#39;s DNS needs:</p><pre>/** Production hosts the Worker answers through its routes; each needs a proxied DNS record to exist. */<br>export const WORKER_HOSTS = [HOSTS.production.www, ...Object.values(HOSTS.production.apps)]<br> <br>/**<br> * What a Worker host&#39;s DNS records need: &#39;ok&#39;, &#39;create&#39; (none yet), &#39;proxy&#39; (our placeholder,<br> * orange cloud off) or &#39;conflict&#39; (something else lives there; never overwritten, a human decides).<br> */<br>export function workerHostAction(records) {<br>  if (records.length === 0) return &#39;create&#39;<br>  const ours = records.length === 1 &amp;&amp; records[0].type === &#39;AAAA&#39; &amp;&amp; records[0].content === &#39;100::&#39;<br>  if (!ours) return &#39;conflict&#39;<br>  return records[0].proxied ? &#39;ok&#39; : &#39;proxy&#39;<br>}</pre><p>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 CONFLICT, left alone and exits non-zero. A dry run prints would create without changing anything.</p><p>WORKER_HOSTS is built from the same host map the routes and the redirects come from, so a new app can&#39;t get a route without getting a DNS row. A test checks that, and checks each decision:</p><pre>test(&#39;every Worker host gets a proxied AAAA 100:: placeholder; a missing one is created, a foreign one is never overwritten&#39;, async () =&gt; {<br>  const { WORKER_HOSTS, workerHostAction } = await import(&#39;./zone-rules.mjs&#39;)<br>  for (const app of Object.values(HOSTS.production.apps)) assert.ok(WORKER_HOSTS.includes(app), `${app} has no placeholder row`)<br>  assert.ok(WORKER_HOSTS.includes(HOSTS.production.www))<br>  assert.equal(workerHostAction([]), &#39;create&#39;)<br>  assert.equal(workerHostAction([{ type: &#39;AAAA&#39;, content: &#39;100::&#39;, proxied: true }]), &#39;ok&#39;)<br>  assert.equal(workerHostAction([{ type: &#39;AAAA&#39;, content: &#39;100::&#39;, proxied: false }]), &#39;proxy&#39;)<br>  assert.equal(workerHostAction([{ type: &#39;CNAME&#39;, content: &#39;cname.vercel-dns.com&#39;, proxied: false }]), &#39;conflict&#39;)<br>})</pre><h3>The dry run found more than DNS</h3><p>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 (early_hints, fonts and automatic_https_rewrites were &quot;on&quot; again). I almost dismissed the drift as default noise. early_hints is off on purpose on this zone, so the repo&#39;s value wins and the script set it back.</p><h3>A subdomain is done when it answers</h3><p>The rule I wrote down after this: a new Worker subdomain is done when pnpm cf:zone --production prints its host as ok and the production check (pnpm check:prod), which requests every app host and follows its redirect, is green. A merged commit doesn&#39;t count, and neither does a green deploy.</p><h3>Takeaways</h3><ul><li>A Worker route doesn’t create DNS. Each hostname needs a proxied record, or the name doesn’t resolve and the route never runs.</li><li>When the Worker is the origin, use a proxied AAAA 100::. It points nowhere if the proxy is ever turned off.</li><li>Derive the DNS check from the same list as the routes, and let the script create the record instead of a checklist.</li><li>Never let automation overwrite a record it didn’t create. Report the conflict and fail.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8120180fd130" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.js ships dangerouslySetInnerHTML twice: once in the HTML, once in the RSC payload]]></title>
            <link>https://medium.com/@boogado66/next-js-ships-dangerouslysetinnerhtml-twice-once-in-the-html-once-in-the-rsc-payload-813488443733?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/813488443733</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 17:17:45 GMT</pubDate>
            <atom:updated>2026-11-26T17:17:45.081Z</atom:updated>
            <content:encoded><![CDATA[<p>In the Next.js App Router, a server component that renders HTML with dangerouslySetInnerHTML sends that HTML twice: once in the page&#39;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.</p><p>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.</p><h3>Why does the RSC payload contain my HTML?</h3><p>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 self.__next_f.push([...]) script calls.</p><p>Props are part of that tree. dangerouslySetInnerHTML={{ __html: html }} 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.</p><h3>How to see it on your own page</h3><p>Weigh the parts of the built HTML instead of guessing. Sum the self.__next_f.push script bodies, then measure the article element on its own. On my page:</p><ul><li><strong>RSC payload</strong> — 280 KB</li><li><strong>Article (59 KB of text, 122 KB of markup)</strong> — 181 KB</li><li><strong>Everything else</strong> — ~50 KB</li></ul><p>One trap: if the article itself quotes self.__next_f.push(...), as this one does, a regex over the page matches the prose as well. Count only inside &lt;script&gt; tags.</p><p>My first idea was trimming the image markup (long CDN URLs, alt text repeated in aria-label). That&#39;s about 20% of the article and does nothing about the copy, which grows with every section the article gains.</p><h3>The fix: render an empty marker, fill it after the build</h3><p>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:</p><pre>export function StaticHtml({ id, html, className }: Props) {<br>  if (process.env.NODE_ENV !== &#39;production&#39;) {<br>    return (<br>      &lt;div className={className} dangerouslySetInnerHTML={{ __html: html }} /&gt;<br>    )<br>  }<br>  recordStaticHtml(id, html)<br>  return (<br>    &lt;div<br>      className={className}<br>      data-static-html={id}<br>      suppressHydrationWarning<br>      dangerouslySetInnerHTML={{ __html: &#39;&#39; }}<br>    /&gt;<br>  )<br>}</pre><p>The payload now carries an empty string. recordStaticHtml writes the body to .next/static-html/&lt;id&gt;.html. next dev has no post-build step, so in development the component renders the HTML directly.</p><p>A script runs right after next build and writes each body into its marker in the exported HTML files:</p><pre>const MARKER = /(&lt;(div|script)\b[^&gt;]*\bdata-static-html=&quot;([^&quot;]+)&quot;[^&gt;]*&gt;)&lt;\/\2&gt;/g<br> <br>export function injectStaticHtml(page, lookup) {<br>  const filled = []<br>  const missing = []<br>  const html = page.replace(MARKER, (whole, open, tag, id) =&gt; {<br>    const body = lookup(id)<br>    if (body == null) {<br>      missing.push(id)<br>      return whole<br>    }<br>    filled.push(id)<br>    return `${open}${body}&lt;/${tag}&gt;`<br>  })<br>  return { html, filled, missing }<br>}</pre><p>It’s wired into the build script (next build &amp;&amp; node scripts/inline-static-html.mjs), 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.</p><h3>Does hydration wipe the body?</h3><p>No. When React hydrates an element with dangerouslySetInnerHTML, it doesn&#39;t rewrite the element&#39;s children to match the prop, so the static body stays in place. suppressHydrationWarning 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 h2s and 83 images, and the console showed no hydration warnings.</p><h3>Client-side navigation gets the empty marker</h3><p>A full page load is covered. A &lt;Link&gt; click is not. The App Router renders the next page from its RSC payload (the .txt file next to the HTML), and that payload now holds an empty body.</p><p>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:</p><pre>export async function fillStaticHtml(): Promise&lt;boolean&gt; {<br>  const markers = [...document.querySelectorAll&lt;HTMLElement&gt;(EMPTY)]<br>  if (markers.length === 0) return true<br>  const path = window.location.pathname.replace(/\/$/, &#39;&#39;) || &#39;/&#39;<br>  const html = await warmPage(path)<br>  pages.delete(path)<br>  const source = new DOMParser().parseFromString(html, &#39;text/html&#39;)<br>  const bodies = new Map(<br>    [...source.querySelectorAll&lt;HTMLElement&gt;(MARKER)].map((el) =&gt; [<br>      el.dataset.staticHtml ?? &#39;&#39;,<br>      el.innerHTML,<br>    ])<br>  )<br>  const filled = fillMarkers(markers, (id) =&gt; bodies.get(id) ?? null)<br>  if (filled.length) window.dispatchEvent(new Event(FILLED_EVENT))<br>  return !hasEmptyMarker()<br>}</pre><p>That HTML file is cached at the CDN (about 49 KB brotli for the biggest page). A small client component starts the fetch on pointerover, touchstart or focusin of an article link, so it usually lands before the click does. The reload stayed as a fallback, guarded by a sessionStorage key so a broken build can&#39;t loop. If it fires, it reports an error to analytics.</p><h3>Anything that reads the article DOM has to re-run</h3><p>When the body is filled after mount, anything that read the article on mount has read an empty one:</p><ul><li><strong>The section rail and the outline observers</strong> would find no headings. They re-run when the fill event fires, through a hook that bumps a counter on static-html:filled, and that counter sits in their effect deps.</li><li><strong>The read beacon</strong>, 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.</li></ul><h3>JSON-LD goes through the same marker</h3><p>JSON-LD &lt;script&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 div[data-static-html]. With a bare [data-static-html]:empty, the never-filled JSON-LD script matched as &quot;still empty&quot;, so the beacon would never fire and the fallback would reload.</p><h3>Results</h3><ul><li><strong>Longest case study</strong> — Before: 512 KB; After: 262 KB (payload 42 KB)</li><li><strong>Project list</strong> — Before: 410 KB; After: 398 KB</li></ul><p>That’s 270 bodies across 87 pages, and all 3,047 JSON-LD blocks still parse.</p><h3>When this is worth doing</h3><p>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.</p><p>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 dangerouslySetInnerHTML ships twice. For the other things that made my list page heavy (repeated SVG paths, copied JSON-LD, class strings), see <a href="https://www.mohamedgado.com/writing/nextjs-page-weight-rsc-payload">Cutting a Next.js page from 854 KB to 459 KB</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=813488443733" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why GitHub shows a red X on commits whose deploys succeeded: cancel-in-progress]]></title>
            <link>https://medium.com/@boogado66/why-github-shows-a-red-x-on-commits-whose-deploys-succeeded-cancel-in-progress-413cd56b6600?source=rss-64ca877889d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/413cd56b6600</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Mohamed Gado]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 17:14:59 GMT</pubDate>
            <atom:updated>2026-11-26T17:14:59.530Z</atom:updated>
            <content:encoded><![CDATA[<p>A GitHub Actions run cancelled by concurrency: cancel-in-progress: true puts a red X on its commit, the same mark a failed run gets. For three days most commits on my site&#39;s main 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 &quot;cancelled after 1s&quot;. The fix was to keep the debounce and stop cancelling runs: a run that has been superseded exits with code 0 and shows green.</p><h3>Does a cancelled GitHub Actions run count as a failure?</h3><p>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 cancelled conclusion is not success, so the roll-up is a red X, and from the commit list you can&#39;t tell it apart from a broken build. You have to open the run to see the word &quot;cancelled&quot;.</p><p>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.</p><h3>The workflow that produced it</h3><p>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 concurrency to drop the waiting runs when a newer push arrived:</p><pre>concurrency:<br>  group: production<br>  cancel-in-progress: true<br> <br>jobs:<br>  deploy:<br>    runs-on: ubuntu-latest<br>    env:<br>      DEBOUNCE_SECONDS: 180<br>      HOOK: ${{ secrets.CF_DEPLOY_HOOK }}<br>    steps:<br>      - name: Wait for the push burst to settle<br>        run: sleep &quot;$DEBOUNCE_SECONDS&quot;<br>      - name: Trigger the Cloudflare Workers Builds deploy hook for main<br>        run: curl -fsS -X POST &quot;$HOOK&quot;</pre><p>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.</p><p>A habit made it worse. To skip the three-minute wait, sessions ran gh workflow run deploy.yml 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&#39;t show on the commit, so the only check left on the commit was the cancelled one.</p><h3>How I traced it</h3><p>I checked the layers in order, from the symptom toward the deploy:</p><ol><li><strong>Actions run conclusions</strong> for the deploy workflow: no failure at all, only cancelled and success.</li><li><strong>Cloudflare’s builds API</strong>: every build in the window succeeded.</li><li><strong>Pairing timestamps</strong>: each cancelled push run had a workflow_dispatch run that started in the same second, or a newer push run.</li></ol><p>So the red X’s didn’t come from any failure. The workflow’s own design created them.</p><h3>The fix: debounce without cancelling</h3><p>The run still waits, but it no longer depends on being cancelled. After the wait it asks GitHub which commit main points at. If that is not its own commit, a newer push has arrived and that push&#39;s run will deploy, so this run exits 0:</p><pre>jobs:<br>  deploy:<br>    runs-on: ubuntu-latest<br>    timeout-minutes: 10<br>    env:<br>      DEBOUNCE_SECONDS: ${{ github.event_name == &#39;workflow_dispatch&#39; &amp;&amp; 0 || 180 }}<br>      HOOK: ${{ secrets.CF_DEPLOY_HOOK }}<br>      GH_TOKEN: ${{ github.token }}<br>    steps:<br>      - name: Wait for the push burst to settle<br>        run: sleep &quot;$DEBOUNCE_SECONDS&quot;<br>      - name: Trigger the Cloudflare Workers Builds deploy hook for main<br>        run: |<br>          if [ &quot;$GITHUB_EVENT_NAME&quot; = &quot;push&quot; ]; then<br>            HEAD=$(gh api &quot;repos/$GITHUB_REPOSITORY/commits/main&quot; --jq .sha)<br>            if [ &quot;$HEAD&quot; != &quot;$GITHUB_SHA&quot; ]; then<br>              echo &quot;::notice::Superseded: main is at ${HEAD:0:7}, its own run deploys it.&quot;<br>              exit 0<br>            fi<br>          fi<br>          curl -fsS -X POST &quot;$HOOK&quot;</pre><p>The concurrency block is gone. Three things changed:</p><ul><li><strong>A superseded run is green.</strong> It ends with a notice that names the newer commit, so the run log still explains why it didn’t deploy.</li><li><strong>Only the head deploys.</strong> Only one SHA can be the head of main, so a burst still collapses into one deploy: the run for the last push.</li><li><strong>A manual dispatch skips the wait.</strong> DEBOUNCE_SECONDS is 0 for workflow_dispatch, so nobody has a reason to dispatch right after a push. After a push, you wait about four minutes and the push run deploys.</li></ul><p>gh is preinstalled on GitHub-hosted runners and reads GH_TOKEN, and the default github.token with contents: read can read the commit. No extra secret is needed.</p><h3>The cost</h3><p>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. cancel-in-progress hid that cost because cancelled runs stop early. If minutes get tight, lower DEBOUNCE_SECONDS. You get less collapsing, and the commits stay green.</p><h3>Pin it with a test</h3><p>A workflow file is easy to “simplify” back into the old shape, because cancel-in-progress looks like the obvious tool for this. A test that reads the YAML keeps it from coming back:</p><pre>test(&#39;bursts become one deploy without cancelling: a superseded run exits green&#39;, () =&gt; {<br>  assert.doesNotMatch(workflow, /cancel-in-progress:\s*true/)<br>  assert.match(workflow, /commits\/main/)<br>  assert.match(workflow, /&quot;\$HEAD&quot; != &quot;\$GITHUB_SHA&quot;[\s\S]*exit 0/)<br>})<br> <br>test(&#39;a manual dispatch deploys at once, so nobody dispatches to skip the wait&#39;, () =&gt; {<br>  assert.match(workflow, /github\.event_name == &#39;workflow_dispatch&#39; &amp;&amp; 0 \|\| \d+/)<br>})</pre><h3>When cancel-in-progress is still right</h3><p>For pull request checks, cancel-in-progress 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.</p><h3>Takeaways</h3><ul><li>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.</li><li>Debounce by waiting and then checking whether your commit is still the head of the branch, not by cancelling.</li><li>Before you chase a red X, open the run. “Cancelled after 1s” means a concurrency group cancelled it, not that a build broke.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=413cd56b6600" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>