<p dir="auto">We have this bug in various places where AbortController is used. It happens like this:</p>
<ol dir="auto">
<li>you enable data layer and <code class="notranslate">getData()</code> is called</li>
<li><code class="notranslate">getData()</code> checks if <code class="notranslate">dataLoader</code> is defined and it's not defined</li>
<li><code class="notranslate">getData()</code> initializes <code class="notranslate">dataLoader</code> with a new <code class="notranslate">AbortController</code> and passes its signal to <code class="notranslate">fetch</code></li>
<li>before the loading is finished you move the map and <code class="notranslate">getData()</code> is called again</li>
<li><code class="notranslate">getData()</code> checks if <code class="notranslate">dataLoader</code> is defined, now it is</li>
<li><code class="notranslate">getData()</code> calls <code class="notranslate">dataLoader.abort()</code> which schedules the abort event</li>
<li><code class="notranslate">getData()</code> overwrites <code class="notranslate">dataLoader</code> with the second <code class="notranslate">AbortController</code> and passes its signal to the second <code class="notranslate">fetch</code>; the first <code class="notranslate">fetch</code> is still running</li>
<li>after the execution returns to the event loop, abort event happens and the first <code class="notranslate">fetch</code> is cancelled</li>
<li><code class="notranslate">.finally</code> of the first <code class="notranslate">fetch</code> is reached and <code class="notranslate">dataLoader</code> is cleared, this deletes the reference to <em>the second <code class="notranslate">AbortController</code></em></li>
</ol>
<p dir="auto">Now it's impossible to abort the second <code class="notranslate">fetch</code>. If you move the map around faster than the fetches finish, you'll notice that only every other of them gets cancelled.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/openstreetmap/openstreetmap-website/pull/5893'>https://github.com/openstreetmap/openstreetmap-website/pull/5893</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/5893/commits/5521fa6ba3e77b97146b959b46d7ee209bc08a2b" class="commit-link">5521fa6</a>  Keep reference to AbortController on AbortError in data layer</li>
</ul>

<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/5893/files">1 file</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5893/files#diff-ef1a25386d3acf1a86026dcc1edba5a3ec22fc64053d657cb1564b25129475c6">app/assets/javascripts/index/layers/data.js</a>
    (5)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/5893.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/5893.patch</a></li>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/5893.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/5893.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5893">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMWUXCQG2UXJLLZ75T2YAA5HAVCNFSM6AAAAAB2QVTCHKVHI2DSMVQWIX3LMV43ASLTON2WKOZSHE3TIMZTHE2DAOA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLOFJ7ATXJIZQIIHHST2YAA5HA5CNFSM6AAAAAB2QVTCHKWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHLCSGRKA.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5893</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5893",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5893",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>