condition-based-waiting

Replace arbitrary timeouts with condition polling in asynchronous tests.

4|1|Updated Oct 29, 2025
One-click install
npx skills add https://github.com/bacchus-labs/wrangler --skill condition-based-waiting-bacchus-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: condition-based-waiting
Source: https://github.com/bacchus-labs/wrangler/tree/main/.wrangler/memory/knowledge-base/reference-prompts/skills/condition-based-waiting
Command: npx skills add https://github.com/bacchus-labs/wrangler --skill condition-based-waiting-bacchus-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses flaky tests and unreliable asynchronous operations caused by arbitrary timeouts, ensuring your code waits for actual conditions to be met rather than guessing at durations.

Core Features & Use Cases

  • Replaces arbitrary timeouts: Eliminates setTimeout or sleep in tests.
  • Condition polling: Waits for specific states, events, or data changes.
  • Use Case: When a test intermittently fails because it assumes an API response will arrive within a fixed time, this skill can be used to poll for the actual presence of the response data, making the test robust.

Quick Start

Use the condition-based-waiting skill to wait until the user data is available in the system.

Frequently Asked Questions about condition-based-waiting

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

FAQPage Schema
How do I fix flaky tests caused by race conditions and arbitrary timeouts?

To fix flaky tests caused by race conditions, replace arbitrary timeouts with condition polling to wait for actual states or data changes. This ensures tests pass reliably by verifying conditions are met rather than guessing durations.

What is condition polling in asynchronous operations?

Condition polling in asynchronous operations continuously checks for a specific state, event, or data change instead of pausing execution for a fixed duration. It provides robust coordination by reacting to actual system readiness.

How do I wait for an API response in tests without using sleep or setTimeout?

You wait for an API response in tests by using generic polling functions to check for the actual presence of the response data. This event-based waiting approach eliminates timing dependencies and intermittent failures.

Does condition-based waiting work with event-based asynchronous architectures?

Yes, condition-based waiting works with event-based asynchronous architectures by preferring event-based waiting when available. It provides domain-specific helpers to robustly coordinate operations across different asynchronous patterns.

When should I replace arbitrary timeouts with condition polling?

You should replace arbitrary timeouts with condition polling when tests exhibit intermittent pass/fail behavior, timing dependencies, or race conditions. It ensures code waits for actual conditions to be met robustly.