Skip to content

fix(batch): validate concurrency and rate-limit pause config - #1016

Closed
neverm1ndthat wants to merge 1 commit into
Stellar-split:mainfrom
neverm1ndthat:fix/1009-1010-batch-validation
Closed

neverm1ndthat wants to merge 1 commit into
Stellar-split:mainfrom
neverm1ndthat:fix/1009-1010-batch-validation

Conversation

@neverm1ndthat

Copy link
Copy Markdown

Fixes #1009 and #1010

Summary

Validates InvoiceBatchProcessor configuration and makes the rate-limit backoff monotonic.

Issue #1010 - Concurrency bounds

The old code accepted non-integer, negative, zero, NaN, and Infinity values for maxConcurrent. Infinity or extremely large integers could stall the initial launch loop.

Fix:

  1. Reject maxConcurrent that is not a positive integer before any dispatch
  2. Cap initial launch count at Math.min(maxConcurrent, invoiceIds.length)

Issue #1009 - Rate-limit pause authority

The old code accepted negative, fractional, NaN, and Infinity pauses. A second worker with a shorter Retry-After hint could shorten the shared pause. A worker falling asleep before a longer hint arrived would dispatch immediately on wake.

Fix:

  1. Validate rateLimitPauseMs is a non-negative integer
  2. Validate Retry-After hints via isValidPauseMs before using them
  3. Make pausedUntil monotonic: pausedUntil = Math.max(pausedUntil, nextPausedUntil)
  4. Workers recheck the pause deadline after each sleep via waitForGlobalPause() loop

Testing

  • All 6 existing tests in test/invoiceBatchProcessor.test.ts continue to pass
  • No new files or dependencies introduced

Issue Stellar-split#1010 - reject invalid maxConcurrent values (non-integer, <= 0, NaN,
Infinity) before any dispatch, and cap initial launch loop at min(maxConcurrent,
invoiceIds.length) so extremely large values do not stall.

Issue Stellar-split#1009 - validate rateLimitPauseMs, make retryAfterMs fall back safely on
malformed hints, enforce monotonic pausedUntil (Math.max), and recheck the
shared pause deadline after each sleep so workers do not wake early.
@neverm1ndthat

Copy link
Copy Markdown
Author

Hi @Kingsman-99! This PR addresses Issues #1009 and #1010 - validates InvoiceBatchProcessor config (maxConcurrent must be positive int, rateLimitPauseMs must be non-negative), makes the rate-limit pause deadline monotonic, and caps initial launches at invoice count. All existing tests pass. PTAL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: batch workers can dispatch before the shared 429 pause expires

2 participants