Skip to content
Source
Sign inSign up
TanStack/pacer

docs(batcher): explain that wait restarts on every addItem #290

OpenMFA-G(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/290/headopened

🎯 Changes

Fixes #289.

Batcher, AsyncBatcher, and LiteBatcher clear and restart the wait timer on every addItem call, so wait is time since the last item was added. The wait option JSDoc called it the "maximum time to wait before processing a batch", and the class example said "After 2 seconds or when 5 items are added". Both read like a fixed window counted from the first item. The batching guides already describe it correctly ("Every added item restarts the timer").

This PR changes:

  • The wait option doc in BatcherOptions, AsyncBatcherOptions, and LiteBatcherOptions now says the timer restarts on each addItem.
  • The class examples now say "2 seconds after the last item is added, or as soon as 5 items are added, whichever comes first".
  • The asyncBatch options list now says wait is counted from the last added item.
  • I regenerated docs/reference with pnpm generate-docs and only kept the pages for these comments.

Only comments and generated docs change; runtime behavior is the same.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request. (Docs-only. I ran test:eslint, test:types, test:lib, and build for @tanstack/pacer and @tanstack/pacer-lite, plus prettier --check on the changed files.)
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Documentation
    • Clarified that the batch wait period starts over whenever an item is added, and processing occurs after the configured time passes without new items.
    • Updated examples to explain that reaching the batch size limit can trigger processing before the wait period ends.
    • Aligned descriptions across batcher options, classes, and the async batching function.
    1. ⚠️ No Changeset found

      Latest commit: 43da8447ef4cf77243d56ccb6257c9e1507da9c2

      Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

      This PR includes no changesets

      When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

      Click here to learn what changesets are, and how to add one.

      Click here if you're a maintainer who wants to add a changeset to this PR

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Repository: TanStack/pacer/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 4e7f3245-1194-4667-aac1-34ebeac9c23a

      📥 Commits

      Reviewing files that changed from the base of the PR and between 2fce0b792ff2288822f48baa590eb318c1517a5c and 43da8447ef4cf77243d56ccb6257c9e1507da9c2.


      📒 Files selected for processing (8)
      • docs/reference/classes/AsyncBatcher.md
      • docs/reference/classes/Batcher.md
      • docs/reference/functions/asyncBatch.md
      • docs/reference/interfaces/AsyncBatcherOptions.md
      • docs/reference/interfaces/BatcherOptions.md
      • packages/pacer-lite/src/lite-batcher.ts
      • packages/pacer/src/async-batcher.ts
      • packages/pacer/src/batcher.ts

      Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.



      📝 Walkthrough

      Walkthrough

      Documentation for Batcher, AsyncBatcher, and related APIs now describes wait as a quiet period measured from the most recently added item. Examples clarify that reaching the batch size limit can trigger processing first.

      Changes

      Batch wait documentation

      Layer / File(s)Summary
      Clarify trailing wait semantics
      packages/pacer/src/batcher.ts, packages/pacer/src/async-batcher.ts, packages/pacer-lite/src/lite-batcher.ts, docs/reference/interfaces/BatcherOptions.md, docs/reference/interfaces/AsyncBatcherOptions.md, docs/reference/functions/asyncBatch.md, docs/reference/classes/Batcher.md, docs/reference/classes/AsyncBatcher.md
      The option descriptions state that each added item restarts the wait timer. Examples state that processing occurs after the quiet period or when the batch reaches five items, whichever occurs first.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Other

      Suggested reviewers: kevinvandy


      Merge Risk: ⚪ Minimal · up to 43da8

      The documentation clarifies when batches are processed, and no actionable merge risk is evident. The PR is ready for normal checks.

      Pre-merge checks | Passed 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Description checkPassedThe description follows the repository template. It clearly explains the documentation changes, motivation, testing, checklist status, and release impact. It also states that runtime behavior is uncha…
      Title checkPassedThe title clearly and concisely describes the main change: documenting that the wait timer restarts on every addItem call.
      Linked Issues checkPassedIssue #289 requires documentation that wait measures quiet time after the most recent addItem, and that examples state the last-item timing and maxSize condition. The source comments for `Batche…
      Out of Scope Changes checkPassedThe diff changes only source comments and the corresponding generated reference pages. Each change documents the wait behavior from issue #289 or keeps generated documentation synchronized with thos…
      Docstring CoveragePassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share

      Comment `@coderabbitai help` to get the list of available commands.
    3. MFA-G(GitHub profile, opens in a new tab) linked this to fix #289

Sign in to join this conversation.