Test/prismascope concurrency#967
Open
wonderfulmarv01 wants to merge 4 commits into
Open
Conversation
- Implemented GET /api/orgs/:orgId/analytics/risk endpoint to retrieve risk metrics for organizations. - Added logic to calculate slash rate and capital at risk based on vault data. - Introduced new OrgRiskAnalyticsVault and OrgRiskAnalyticsResponse interfaces for structured data handling. - Created unit tests to validate the new endpoint functionality and ensure accurate metric calculations.
|
@wonderfulmarv01 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.
closes #736
PR Summary: Add Concurrency Stress Test for Prisma Scoped Context
Overview
This PR adds a comprehensive concurrency stress test for the request-scoped Prisma client context managed by AsyncLocalStorage in src/lib/prismaScope.ts. The goal is to prove that the request-scoped Prisma context remains perfectly isolated and never bleeds or leaks across overlapping concurrent requests.
Changes
New Test File:
prismaScope.concurrency.test.ts
Uses Bun's native test runner (bun test) and its built-in module mocking (mock.module).
Launches 1,000 concurrent requests simultaneously using Promise.all.
Verifies scope isolation across nested awaits (3+ levels deep).
Crosses event loop boundaries (timer hops) using setTimeout, setImmediate, and process.nextTick with randomized delays.
Asserts that the scope is preserved and correctly bound within catch blocks and after error handling (error path scope).
Asserts that when outside of any active scope, getPrisma() correctly falls back to the global Prisma singleton.
Fully compliant with the project's ESLint configuration (zero lint errors/warnings).
Verification & Testing
Concurrency Stress Test:
bash
bun test src/tests/prismaScope.concurrency.test.ts
Result: Passed (2/2 tests, 16,002 assertions) in 241.66ms.
Regression Testing:
bash
npm run test src/tests/prismaScope.test.ts
Result: Passed (All 7 existing Jest tests passed successfully).