Skip to content
Esc

@noctcore/eslint-plugin-async-safety

v1.0.07 rules4 recommended3 opt-innamespace noctcore-async-safety

A bad fit for browser-only code that relies on the platform's own fetch lifetime, and for scripts where hanging is harmless.

Async correctness TypeScript cannot catch: unbounded fetch, dropped AbortSignals, concurrency races.

An async bug usually type-checks. A fetch with no timeout hangs a worker forever, a function that accepts an AbortSignal and never forwards it cannot be cancelled, two iterations of a Promise.all(arr.map(async ...)) read and write the same counter and lose an update, a module-level variable written in a request handler leaks between requests.

It will yell at you about timeouts and cancellation first: require-fetch-timeout fires on every bare fetch, which is intentional and noisy on first run. no-shared-mutable-module-state and require-client-timeout ship enabled but inert until you tell them which files are server code and which clients to check. Timeouts and parallelism change runtime behaviour, so the fixes are editor suggestions, never autofixes. prefer-parallel-awaits ships off: sequential awaits are often deliberate. It is a bad fit for browser-only code that relies on the platform’s own fetch lifetime, and for scripts where hanging is harmless.

Install
npm install --save-dev @noctcore/eslint-plugin-async-safety @typescript-eslint/parser
# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-async-safety @typescript-eslint/parser

The recommended preset enables 4 of 7 rules. The rules board below builds the flat config: start from a preset, switch single rules between error and off, and copy the result.

Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first read is forward-abort-signal.

4 of 7 at error

--fixsuggestionsneeds optionstype infoEach switch sets a rule to error or off.

forward-abort-signal
A function that accepts an AbortSignal (param named signal or typed AbortSignal) but awaits a call without ever forwarding it leaves that work uncancellable.
recommended
no-concurrent-shared-mutation
A read-modify-write of an outer-scope binding that awaits between the read and the write, inside a concurrent Promise.all(arr.map(async …)) callback, can lose updates.
recommended
no-leaky-race-timeout
A setTimeout timeout raced with Promise.race must be cleared — otherwise the timer outlives the race whenever the other promise wins.
recommended
no-shared-mutable-module-state
A module-scoped mutable binding written inside an exported async/handler function or an exported class method is shared across concurrent requests. Opt in per file via include.
Needs options
opt-in
prefer-parallel-awaits
Consecutive independent const x = await read() statements can run concurrently via await Promise.all([...]).
Editor suggestions
opt-in
require-client-timeout
A configured network client must be constructed with a timeout option; an unbounded client can hang forever.
Needs options
opt-in
require-fetch-timeout
A fetch (or configured wrapper) call must carry a signal/timeout in its options — an unbounded request can hang forever.
Editor suggestions
recommended