refactor: simplify rate limiter and enhance frontend error handling - #384
Merged
Conversation
|
@Folex1275 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
Fixes four bugs across the rate limiter middleware and transaction history
component.
fix(rateLimiter): remove redundant whitelist check in default export (#227)
The default
rateLimiterexport manually calledisWhitelisted()beforedelegating to
createRateLimiter(), which already has askipoption thatcalls
isWhitelisted(). This caused every whitelisted IP to be checked twiceper request.
Replaced the hand-rolled wrapper function with a single pre-built
createRateLimiter()instance as the default export. Theskipoption insidecreateRateLimiteris now the sole whitelist gate.Closes #227
fix(TransactionHistory): surface fetch errors instead of swallowing them (#228)
The
fetchPagecatch block was empty, leaving the component stuck in a loadingstate with no feedback when the API call failed. The parent
Appcomponentdoes not handle errors from
TransactionHistory, so errors were silently lost.Added an
errorstate that captures the error message. When set, an errorbanner with a Retry button is rendered in place of the transaction list.
Retrying re-fetches the current page (preserving cursor position).
Closes #228
fix(TransactionHistory): cap cursor history to prevent unbounded growth (#229)
The
cursorsarray grew by one entry on every "Next" click with no upperbound. After navigating many pages the array could hold hundreds of cursor
strings in memory.
Capped the cursor stack at 50 entries (
MAX_CURSOR_HISTORY). When the limitis exceeded, the oldest entry is dropped (sliding window), so back-navigation
still works for the most recent 50 pages.
Closes #229
fix(App): abort axios request when withTimeout fires (#230)
withTimeoutpreviously raced asetTimeoutrejection against the axiospromise. When the timeout won, the axios request continued running in the
background, consuming bandwidth and potentially resolving after the user had
already seen an error.
Refactored
withTimeoutto accept a factory function(signal) => promise.It creates an
AbortController, passes the signal to axios via thesignaloption, and calls
controller.abort()when the timeout fires. Updated allthree call sites (
createAccount,checkBalance,sendPayment) accordingly.Also removed a duplicate
const { data }declaration insendPaymentthatwas left over from a previous edit.
Closes #230