added local store to not have a bad closure#49
Conversation
🦋 Changeset detectedLatest commit: 5caf6c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Fixed issue with correlation ID and Tenant separation in concurrent calls.
There was a problem hiding this comment.
Pull request overview
This PR updates the tenant and correlation context accessors to use AsyncLocalStorage with per-scope stored values (instead of a shared Map), preventing context leakage across concurrent async requests.
Changes:
- Refactor tenant context storage to store the
TenantContextdirectly inAsyncLocalStorage. - Refactor correlation ID storage to store the correlation ID string directly in
AsyncLocalStorage. - Add concurrency tests to validate isolation of tenant context and correlation IDs across parallel async flows.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/multitenancy-core/src/tenantContextAccessor.ts | Stores TenantContext directly in AsyncLocalStorage instead of using a shared Map. |
| packages/multitenancy-core/tests/tenant-context-accessor.text.ts | Adds a concurrency test intended to ensure tenant contexts don’t bleed across concurrent requests. |
| packages/correlation/src/correlationManager.ts | Stores correlation ID directly in AsyncLocalStorage instead of using a shared Map. |
| packages/correlation/tests/correlation.test.ts | Adds a concurrency test to ensure correlation IDs don’t mix across concurrent requests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….com/osstotalsoft/rocket-toolkit into bugfix/separate-tenant-context-store
No description provided.