fleet-plugging-promise-race

Replace persistent promise pools with fresh per-iteration signals in JavaScript loops.

125|42|Updated May 19, 2025
One-click install
npx skills add https://github.com/SocketDev/socket-mcp --skill fleet-plugging-promise-race
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fleet-plugging-promise-race
Source: https://github.com/SocketDev/socket-mcp/tree/main/.agents/skills/fleet-plugging-promise-race
Command: npx skills add https://github.com/SocketDev/socket-mcp --skill fleet-plugging-promise-race

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Solves cross-iteration promise leakage by ensuring each loop cycle awaits a fresh signal instead of reusing a pool.

Core Features & Use Cases

  • Safe, single-waiter pattern: replaces a persistent pool with a fresh, per-iteration signal.
  • Correct concurrency semantics: prevents handler accumulation in Promise.race/Promise.any across iterations.
  • Use case: when implementing iterative concurrency limits in JavaScript/Node.js code that races multiple async tasks.

Quick Start

Replace the persistent pool of promises with a single-waiter signal so every loop iteration awaits a fresh promise.

Frequently Asked Questions about fleet-plugging-promise-race

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

FAQPage Schema
Why does Promise.race leak memory across iterations in Node.js?▼

Promise.race leaks memory across iterations because reused persistent promises accumulate handlers. Replacing the promise pool with a fresh per-iteration signal eliminates this handler buildup and ensures correct concurrency semantics.

How do I prevent promise handler accumulation when racing async tasks in a loop?▼

You prevent promise handler accumulation by implementing a single-waiter pattern that replaces the persistent promise pool with a fresh, replaceable signal awaited during each iterative loop cycle.

What is a single-waiter pattern for JavaScript concurrency control?▼

A single-waiter pattern for JavaScript concurrency control replaces a pool of long-lived promises with a replaceable signal, ensuring each loop iteration awaits a fresh promise to prevent cross-iteration leakage.

Does Promise.any suffer from the same cross-iteration handler leaks as Promise.race?▼

Yes, Promise.any suffers from the same cross-iteration handler leaks when reusing long-lived promises across iterative tasks. Applying a fresh per-iteration signal prevents the handler accumulation that causes these leaks.

How do I implement safe iterative concurrency limits without leaking promises?▼

You implement safe iterative concurrency limits by replacing persistent promise pools with a single-waiter signal, ensuring every loop cycle awaits a fresh promise instead of reusing a shared pool of tasks.