plugging-promise-race

Replace persistent Promise.race handler pools with per-iteration single-waiter signals in iterative concurrency loops.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Never re-race the same pool of promises across loop iterations. A reusable pool of .then handlers can accumulate across iterations, causing leaks and unpredictable behavior in concurrent loops.

Core Features & Use Cases

  • Safer concurrency: adopt a per-iteration single-waiter signal to avoid accumulating handlers.
  • Applies to Promise.race, Promise.any, and other short-circuiting constructs in iterative tasks.
  • Use case: stabilizing a worker loop that waits for several sources to resolve without growing the handler set.

Quick Start

Refactor your loop to create a fresh one-shot signal and await it before starting the next iteration.

Frequently Asked Questions about plugging-promise-race

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

FAQPage Schema
Why does Promise.race leak memory in a JavaScript loop?

A Promise.race leak in a JavaScript loop occurs when a reusable pool of promises accumulates .then handlers across iterations. Re-racing the same persistent pool causes handlers to build up, leading to memory leaks and unpredictable concurrency behavior.

How do I fix Promise.race leaks in an iterative concurrency loop?

Fix Promise.race leaks by refactoring your iterative loop to create a fresh per-iteration single-waiter signal. Awaiting this one-shot signal before the next iteration replaces persistent handler pools and prevents accumulation.

What is a per-iteration single-waiter signal in JavaScript concurrency?

A per-iteration single-waiter signal is a fresh one-shot promise created during each loop iteration. It ensures only one handler waits per cycle, replacing reusable pools to stabilize worker loops and prevent cross-iteration handler accumulation.

Can I use a per-iteration waiter pattern with Promise.any?

Yes, the per-iteration single-waiter pattern applies to Promise.any and other short-circuiting constructs. Applying it to iterative concurrency loops ensures robust behavior by preventing the handler set from growing across iterations.

What are the constraints of using single-waiter signals for race conditions?

Constraints of single-waiter signals include specific failure modes and implementation limits inherent to short-circuiting constructs. Understanding these constraints ensures robust concurrency behavior and avoids unpredictable results in worker loops.