Fix #682, #683, #684, #685: batch size cap, AMM invariant tests, idle connection recycling, one-shot scheduling - #713
Merged
Kingsman-99 merged 1 commit intoAug 29, 2026
Conversation
Closes Stellar-split#682 Closes Stellar-split#683 Closes Stellar-split#684 Closes Stellar-split#685
|
@mercycodes2-sudo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
requestBatcher.ts: constructor now throwsRangeErrorwhenmaxBatchSizeis0; legacyRequestBatcherconfig'smaxBatchSizeis now optional (defaults to unlimited) and forwarded correctly.ammCalculator.ts: addedsrc/__tests__/ammCalculator.test.tsverifying the constant-product invariant (x * y = k) holds after simulated swaps across a range of input sizes, that oversized swaps throwInsufficientLiquidityError, and that a zero-amount swap returns0and leaves reserves untouched.connectionPool.ts: each returned connection now arms its own idle-recycle timer onrelease(), so a slot idle pastidleTimeoutMsis recycled even ifselect()/acquire()is never called again to trigger lazy recycling. Timers are cleared on reuse, recycle, anddispose().scheduler.ts: added aJobSchedulerclass withschedule(intervalMs, fn)for recurring jobs andonce(delayMs, fn)for one-shot jobs. Both return a cancel handle; a one-shot job is removed from the internal job list once it runs (or is cancelled). The two APIs coexist on the same scheduler instance.Test plan
test/requestBatcher.test.ts— new case assertsmaxBatchSize: 0throwsRangeErrorsrc/__tests__/ammCalculator.test.ts— new invariant-preservation teststest/connectionPool.test.ts— new cases cover timer-based recycling on release and non-recycling on reusetest/scheduler.test.ts— new cases coveronce(), cancellation, and coexistence withschedule()Closes #682
Closes #683
Closes #684
Closes #685