Workers - AbortController and AbortSignal can be created at global scope
- Announced
- Tags
- Workers
- Severity
- info, set by
reef/rss-rule-v1 - Source
- https://developers.cloudflare.com/changelog/post/2026-08-19-abort-signal-global-scope/
<p><code>new AbortController()</code>, <code>AbortSignal.abort()</code>, <code>new WritableStream()</code>, and <code>request.signal</code> no longer throw when used during module evaluation (that is, at the top level of your Worker module, outside of a request handler). Previously, these APIs required an active request context and would throw if called at the top level.</p> <figure class="nb-code-figure" data-nb-lang="js"><pre class="astro-code astro-code-themes github-light github-dark nb-shiki-c6xiwz" tabindex="0" data-language="js" data-nb-lang="js"><code><span class="line"><span class="nb-shiki-21nrsd">// This now works — no error during module startup</span></span> <span class="line"><span class="nb-shiki-1itgoe">const</span><span class="nb-shiki-dzsirb"> controller</span><span class="nb-shiki-1itgoe"> =</span><span class="nb-shiki-1itgoe"> new</span><span class="nb-shiki-1t8gfj"> AbortController</span><span class="nb-shiki-140thh">();</span></span> <span class="line"></span> <span class="line"><span class="nb-shiki-1itgoe">export</span><span class="nb-shiki-1itgoe"> default</span><span class="nb-shiki-140thh"> {</span></span> <span class="line"><span class="nb-shiki-1itgoe"> async</span><span class="nb-shiki-1t8gfj"> fetch</span><span class="nb-shiki-140thh">(</span><span class="nb-shiki-1jdh33">request</span><span class="nb-shiki-140thh">) {</span></span> <span class="line"><span class="nb-shiki-21nrsd"> // The signal can be used across requests</span></span> <span class="line"><span class="nb-shiki-1itgoe"> return</span><span class="nb-shiki-1itgoe"> new</span><span class="nb-shiki-1t8gfj"> Response</span><span class="nb-shiki-140thh">(</span><span class="nb-shiki-mdbnqw">"OK"</span><span class="nb-shiki-140thh">, { signal: controller.signal });</span></span> <span class="line"><span class="nb-shiki-140thh"> },</span></span> <span class="line"><span class="nb-shiki-140thh">};</span></span></code></pre></figure> <p>Signals can also be observed and aborted across different requests, making it easier to coordinate cancellation in long-lived Workers such as Durable Objects.</p> <p><code>AbortSignal.timeout()</code> still requires an active request context because it needs to schedule a timer.</p> <p>For more details, refer to the <a href="https://developers.cloudflare.com/workers/runtime-apis/web-standards/#abortcontroller-and-abortsignal">AbortController documentation</a>.</p>
The text above is the source's. reef added the severity, the dates it could read from the text, and the endpoints and scopes named in code.