concurrency-async-patterns

Implements race condition prevention, cancellation, and parallel execution patterns for async TypeScript code.

1|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/dominionism/Noesis --skill concurrency-async-patterns-dominionism
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: concurrency-async-patterns
Source: https://github.com/dominionism/Noesis/tree/main/assets/skills/concurrency-async-patterns
Command: npx skills add https://github.com/dominionism/Noesis --skill concurrency-async-patterns-dominionism

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Concurrent and asynchronous code often fails intermittently due to race conditions, unhandled promise rejections, leaked resources, and missing cancellation support, making bugs hard to reproduce and diagnose. ## Core Features & Use Cases - Fault-Tolerant Parallel Execution: Guidance on choosing between Promise.all, Promise.allSettled, Promise.race, and Promise.any based on whether operations are dependent or independent. - Cancellation and Cleanup: Patterns for AbortController-based timeouts, cancellation propagation through child operations, and guaranteed resource cleanup with try/finally or Symbol.dispose. - Race Condition Prevention: Async mutex implementation, database-level SELECT FOR UPDATE locking, debounce vs. throttle decisions, and concurrency-limited batch processing. - Use Case: When two concurrent requests both read and write an account balance causing lost updates, apply the mutex or transaction pattern to serialize the read-modify-write cycle. ## Quick Start Review my async order processing function for race conditions, missing cancellation support, and unhandled promise rejections.

Frequently Asked Questions about concurrency-async-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent race conditions in async JavaScript code?▼

Race conditions occur when concurrent async operations read-modify-write shared state. Use an async mutex to serialize access in application code, or use database transactions with SELECT FOR UPDATE to lock rows during updates.

When should I use Promise.all vs Promise.allSettled?▼

Use Promise.all when all operations must succeed and results are interdependent. Use Promise.allSettled when operations are independent and partial failure is acceptable, since it returns every result with its fulfillment status.

How do I add a timeout to a fetch request?▼

Create an AbortController, call setTimeout to abort after the timeout, and pass controller.signal to fetch. Always clear the timeout in a finally block so a successful fetch does not leave a timer that fires later.

What is the difference between debounce and throttle?▼

Debounce delays execution until input stops changing, resetting the timer on each call, ideal for search inputs. Throttle executes at most once per interval during continuous activity, ideal for scroll or mouse move handlers.

Why does my Node.js process crash on unhandled promise rejections?▼

Node.js terminates on unhandled rejections because they indicate lost errors. Every promise must be awaited inside try/catch or have a .catch() handler; never fire-and-forget an async call without error handling.

How do I limit concurrency when processing many items in parallel?▼

Use a batch processing pattern that keeps a set of in-flight promises and awaits Promise.race whenever the set reaches the concurrency limit. This processes items in parallel without exhausting connections or memory.