Repository navigation
fix: resolve issues #2090, #2091, #2092, and #2093 - #2337
Merged
K1NGD4VID merged 2 commits intoNov 24, 2026
Merged
Conversation
LabsCrypt#2093 - LabsCrypt#2090: [test] Cover async handler rejected promises - LabsCrypt#2091: [test] Cover rate limiter distributed counters - LabsCrypt#2092: [test] Cover loan access tenant boundaries - LabsCrypt#2093: [test] Cover pause guard state races
Malware detection scan flagged this pull requestThe scan found 2 indicator(s) in the PR diff. This PR is blocked until a maintainer reviews the flagged files.
This is an automated triage signal; maintainers must verify whether the finding is malicious or intentional. |
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
This PR resolves four testing and regression gaps across backend middleware and utility handlers:
[test] Cover async handler rejected promisesasyncHandlerinbackend/src/utils/asyncHandler.tsby wrapping handler invocation intry/catchprior toPromise.resolve, capturing synchronous exceptions before they can escape.backend/src/utils/__tests__/asyncHandler.test.tsfor promise rejections occurring after headers are sent (res.headersSent === true), non-Error normalization with cause/stack preservation, and Express error handling lifecycle integration.[test] Cover rate limiter distributed countersbackend/src/middleware/__tests__/rateLimiter.test.tsfor Redis connection outages and reconnection failures, asserting fail-open behavior (passOnStoreError: true) and degradation alerting.ip:publicKey), and Redis store key prefixing.RateLimit-Limit,RateLimit-Remaining,RateLimit-Reset), legacy header omission,429contract withRetry-After, and quota recovery after window expiration.[test] Cover loan access tenant boundariesbackend/src/middleware/__tests__/loanAccess.test.tsenforcing strict tenant boundaries inrequireLoanOwner(blocking admins, lenders, and unrelated users from claiming ownership).requireLoanBorrowerAccessrole boundaries (admin/lender view authorization vs unrelated user rejection, role casing sensitivity).[test] Cover pause guard state racesbackend/src/middleware/__tests__/pauseGuard.test.tsfor concurrentsetPauseStateoperations and error propagation.updatePauseStateFromDatabase).Verification
npm --prefix backend run typecheckpassed (0 errors).npm --prefix backend run lintpassed (0 errors).npm --prefix backend run format:checkpassed.asyncHandler.test.ts,rateLimiter.test.ts,loanAccess.test.ts, andpauseGuard.test.ts.Closes #2090
Closes #2091
Closes #2092
Closes #2093.