Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
AI & KI NachrichtenAI Restrictions at NYCPS and LAUSD Reverberate Nationwide(24.09.2026 um 01:16 Uhr)
AI & KI NachrichtenMeta Connect 2026: The biggest news and announcements(24.09.2026 um 00:45 Uhr)
AI & KI NachrichtenMeta ditches the camera on its newest smart glasses(24.09.2026 um 01:37 Uhr)
AI & KI NachrichtenMuse is coming to Meta smart glasses(24.09.2026 um 01:40 Uhr)
AI & KI NachrichtenAI Restrictions at NYCPS and LAUSD Reverberate Nationwide(24.09.2026 um 01:16 Uhr)
AI & KI NachrichtenMeta Connect 2026: The biggest news and announcements(24.09.2026 um 00:45 Uhr)
AI & KI NachrichtenMeta ditches the camera on its newest smart glasses(24.09.2026 um 01:37 Uhr)
AI & KI NachrichtenMuse is coming to Meta smart glasses(24.09.2026 um 01:40 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

AbortController & AbortSignal

AbortController is the standard way to cancel async work in modern JavaScript. It pairs with AbortSignal, which you pass to tasks so they can stop immediately. 1) TL;DR Create a controller → pass controller.signal to your a…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

AbortController is the standard way to cancel async work in modern JavaScript. It pairs with AbortSignal, which you pass to tasks so they can stop immediately.









1) TL;DR




  • Create a controller → pass controller.signal to your async work.

  • Call controller.abort(reason?) to cancel; consumers see an AbortError (or signal.reason).

  • Works with fetch, streams, and your own functions.




const c = new AbortController()
const resP = fetch('/api/data', { signal: c.signal })
// later...
c.abort('user navigated away')
try { await resP } catch (e) { if (e.name === 'AbortError') /* ignore */ }












2) Core API (with reason support)






const c = new AbortController()
const { signal } = c

signal.aborted // boolean
signal.reason // any (why it was aborted)

c.abort(new DOMException('Timeout', 'AbortError'))
// or: c.abort('User left the page')







Tip: If you pass a reason, propagate it in your own tasks. fetch will still reject with AbortError.










3) Fetch + Timeouts



A) Easiest: AbortSignal.timeout(ms)




// Modern browsers & Node 18+
const res = await fetch('/slow', { signal: AbortSignal.timeout(3000) })






B) Manual timer




const c = new AbortController()
const id = setTimeout(() => c.abort(new DOMException('Timeout', 'AbortError')), 3000)
try {
const res = await fetch('/slow', { signal: c.signal })
// use res
} catch (e) {
if (e.name !== 'AbortError') throw e
} finally {
clearTimeout(id)
}






C) Race utilities




// winner-takes-all -> cancel the losers
const controllers = [new AbortController(), new AbortController()]
const [a, b] = controllers.map(c => fetch('/mirror', { signal: c.signal }))
const winner = await Promise.any([a, b])
controllers.forEach(c => c.abort('lost the race'))












4) Make Your Own Functions Abortable






export function wait(ms, signal) {
return new Promise((resolve, reject) => {
const id = setTimeout(resolve, ms)
const onAbort = () => { clearTimeout(id); reject(new DOMException('Aborted', 'AbortError')) }
if (signal.aborted) return onAbort()
signal.addEventListener('abort', onAbort, { once: true })
})
}






Propagate reason:




const onAbort = () => reject(signal.reason ?? new DOMException('Aborted', 'AbortError'))












5) Streams & Readers (Browser + Node)






const c = new AbortController()
const res = await fetch('/stream', { signal: c.signal }) // can be aborted
const reader = res.body.getReader({ signal: c.signal }) // abort affects reads too

// later
c.abort()






Node: fetch in Node 18+ also supports abort; for streams, pipe/reader operations should react to abort and close resources.









6) React Patterns



A) Cancel on unmount (and on deps change)




useEffect(() => {
const c = new AbortController()
;(async () => {
try {
const r = await fetch('/api/search?q=' + q, { signal: c.signal })
setData(await r.json())
} catch (e) {
if (e.name !== 'AbortError') console.error(e)
}
})()
return () => c.abort('component unmounted or q changed')
}, [q])






B) Latest-typed value wins (typeahead)




const ref = useRef<AbortController | null>(null)
async function onType(v: string) {
ref.current?.abort('superseded')
const c = new AbortController()
ref.current = c
try {
const r = await fetch('/api?q=' + v, { signal: c.signal })
setOptions(await r.json())
} catch (e) { if (e.name !== 'AbortError') console.error(e) }
}












7) Small Utilities (copy‑paste)






// create a controller that auto-aborts after ms
export const withTimeout = (ms = 5000) => AbortSignal.timeout(ms)

// combine multiple signals -> aborted if ANY aborts
export function anySignal(...signals) {
const c = new AbortController()
const onAbort = (s) => c.abort(s.reason ?? new DOMException('Aborted', 'AbortError'))
signals.forEach(s => s.addEventListener('abort', () => onAbort(s), { once: true }))
return c.signal
}






Usage:




const c = new AbortController()
const s = anySignal(c.signal, AbortSignal.timeout(3000))
fetch('/x', { signal: s })












8) Common Pitfalls & Gotchas





  • Not wiring the signal → pass { signal } everywhere the task supports it.


  • Forgetting cleanup → clear timers and remove listeners on abort (use { once: true }).


  • Swallowing all errors → only ignore AbortError; surface real failures.


  • Global controller reuse → create fresh controllers per operation to avoid accidental cross‑cancels.


  • Overriding reason → if you care about why, use abort(reason) and read signal.reason in custom code.









9) Quick Cheatsheet
































Need Do this
Cancel slow fetch fetch(url, { signal: AbortSignal.timeout(ms) })
Cancel on unmount Create AbortController in useEffect, abort in cleanup
Cancel prior request (search) Keep last controller in ref, abort before new fetch
Cancel a batch Share one controller across requests and call abort()
Keep “why” it was cancelled controller.abort('reason'); signal.reason





Happy cancelling ✨ Use AbortController to keep your apps snappy, correct, and memory‑leak free.



Originally published on: Bitlyst

IR-PLAYBOOK-RCE
HIGH
SOC Incident Playbook: Remote Code Execution (RCE) Defense
1-Click Detection Engineering: Sigma & YARA Rules
SOC Ready
title: Detect Exploitation - AbortController & AbortSignal
id: 0f83b7b1-5376-4260-b6bf-534591fea77d
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "AbortController & AbortSignal" ascii wide
    condition:
        any of them
}
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten AbortController & AbortSignal

Thematisch verwandte Begriffe: AbortController, AbortSignal · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-96676 | A vulnerability was identified in Fast FAC1900R 20190827_2.0.2. The impa…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick