Skip to content

Add unit test coverage for adaptive concurrency throttling #425

Description

@Lakes41

Difficulty: Intermediate
Type: Test
Recommended labels (if available in this repo): tests, sdk

Background

src/access/adaptiveConcurrency.ts implements some form of concurrency throttling for access checks, but based on the repository structure there is no dedicated test file covering its throttling behavior.

Problem

Without test coverage, changes to the throttling algorithm (or accidental regressions from unrelated refactors) could silently break backpressure behavior, risking either RPC overload or unnecessary throttling under normal load.

Expected Outcome

A comprehensive Vitest suite for adaptiveConcurrency.ts covering its core throttling logic under simulated load patterns.

Suggested Implementation

Read through adaptiveConcurrency.ts to identify its current algorithm (e.g. concurrency window, in-flight request counting, backoff triggers). Write tests that simulate bursts of concurrent calls and assert the module correctly limits in-flight requests, and that it recovers concurrency headroom appropriately after load subsides.

Acceptance Criteria

  • Tests cover: normal load (no throttling), burst load (throttling engages), and recovery after burst subsides
  • Tests use fake timers where the module relies on time-based logic, to keep tests fast and deterministic
  • Test file documents the observed algorithm behavior in comments for future maintainers
  • pnpm test:run passes with no flaky failures across 5 consecutive local runs

Likely Affected Files/Directories

  • src/access/adaptiveConcurrency.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewards

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions