fix: harden input validation, pagination clamping, and reconnect backoff - #657
Merged
Jaydbrown merged 5 commits intoSep 1, 2026
Conversation
…uit-protocol#539) Replace linear reconnect delay (delay * attempt) with exponential backoff capped at maxReconnectDelayMs and randomized jitter (0.5-1.0x). Prevents thundering herd when multiple clients reconnect after a server restart.
…onduit-protocol#538) Replace Number-based amount validation with toStroops-based validation that accepts bigint or decimal strings. Rejects Number inputs and scientific notation strings that lose precision for large stroop amounts.
…tocol#537) Add clampOffset() to validate and clamp the offset parameter in streamsBySender/streamsByRecipient. Prevents raw stellar-sdk conversion errors from non-integer, negative, or >2^32-1 offset values.
…nduit-protocol#536) Add guard to reject non-integer, negative, zero, NaN, or Infinity durationSecs inputs. Prevents raw RangeError from BigInt conversion and negative rate/yield outputs.
|
@TheCodingChef-eth 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
Addresses several input-validation and resilience issues across the SDK:
durationSecsvalidation incalculateRate/calculateYield— both helpers now reject non-positive or non-integer durations early instead of silently producing incorrect rate/yield values.offsetclamping —FactoryModule.streams_by_senderandstreams_by_recipientnow clamp the caller-suppliedoffsetto a validu32range via the newclampOffsethelper, preventing an invalid Stellar SDK conversion.amountvalidation —validatePayloadnow acceptsbigintor a decimal string parseable bytoStroops(e.g."1000"or"1.5"), instead of coercing throughNumber, which silently lost precision for large values.delay = min(maxDelay, base * 2^attempts) * random(0.5, 1)) instead of lineardelay * attempts, reducing thundering-herd collisions on reconnect. A newmaxReconnectDelayMsoption caps the upper bound (default 30 s).Changed files
src/utils.tsdurationSecssrc/constants.tsclampOffset()helpersrc/factory.tsclampOffset()to pagination queriessrc/builder.tsamountasbigintor decimal stringsrc/relayer/WebSocketRelayer.tsmaxReconnectDelayMsoptioncloses #536
closes #537
closes #538
closes #539