effect-concurrency-testing

Test Effect concurrency primitives including fibers, PubSub, Deferred, Latch, SubscriptionRef, and Stream.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-concurrency-testing-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-concurrency-testing
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-concurrency-testing
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-concurrency-testing-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Testing concurrent Effect code is error-prone: race conditions, dropped PubSub messages, leaked subscriptions, and misuse of TestClock make tests flaky or non-deterministic. This Skill provides proven patterns for coordinating fibers and verifying concurrent behavior deterministically. ## Core Features & Use Cases - Fiber Coordination Patterns: Use Effect.yieldNow, Latch, Deferred, and fiber.pollUnsafe() to synchronize fibers without arbitrary sleeps or busy polling. - PubSub and SubscriptionRef Testing: Verify published events with scoped subscriptions, readiness signals via Deferred, and latch-gated stream subscriptions so no events are missed. - Stream and Interruption Testing: Collect stream results, verify finalizers with Stream.ensuring, and assert interruption with Exit.hasInterrupts and Cause.hasInterruptsOnly. - Use Case: When testing a service that publishes user events to a PubSub, subscribe inside Effect.scoped, trigger the service action, and assert the exact event sequence with PubSub.takeAll. ## Quick Start Use the effect-concurrency-testing skill to write a deterministic test for my Effect service that publishes events to a PubSub.

Frequently Asked Questions about effect-concurrency-testing

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

FAQPage Schema
How do I test Effect fibers and concurrency in TypeScript?

Use @effect/vitest's it.effect with Effect.gen to fork fibers and coordinate them with Latch, Deferred, or Effect.yieldNow. Check completion non-blockingly with fiber.pollUnsafe() and join results with Fiber.join.

How to test PubSub published events in Effect?

Subscribe inside Effect.scoped so the subscription cleans up automatically, publish events, then assert with PubSub.takeAll or PubSub.takeUpTo. Ensure the subscriber is registered before publishing, since PubSub drops messages sent before subscription.

When should I use TestClock vs Effect.yieldNow in Effect tests?

Use TestClock.adjust only for time-dependent behavior like sleeps, timeouts, or schedules. For simple fiber scheduling without time semantics, use Effect.yieldNow, which is faster and avoids unnecessary clock manipulation.

Why does my SubscriptionRef stream test miss events?

The stream subscription likely starts after the first mutation, so earlier values are never observed. Gate mutations behind a Latch opened by Stream.tap on the changes stream, guaranteeing the subscriber is ready before updates occur.

How do I test fiber interruption in Effect?

Fork the effect, call Fiber.interrupt, then await the fiber and assert on the Exit. Use Exit.hasInterrupts to check for interruption or Cause.hasInterruptsOnly to verify the cause contains only interrupts.