Skip to content

added local store to not have a bad closure#49

Merged
dragos-rosca merged 6 commits into
mainfrom
bugfix/separate-tenant-context-store
Mar 20, 2026
Merged

added local store to not have a bad closure#49
dragos-rosca merged 6 commits into
mainfrom
bugfix/separate-tenant-context-store

Conversation

@dragos-rosca
Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 5caf6c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@totalsoft/correlation Patch
@totalsoft/multitenancy-core Patch
@totalsoft/pino-apollo Patch
@totalsoft/pino-correlation Patch
@totalsoft/pino-mssqlserver Patch
@totalsoft/pino-multitenancy Patch

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

fraliv13
fraliv13 previously approved these changes Mar 20, 2026
Fixed issue with correlation ID and Tenant separation in concurrent calls.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TenantContext directly in AsyncLocalStorage.
  • 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.

Comment thread packages/multitenancy-core/src/tenantContextAccessor.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/multitenancy-core/__tests__/tenant-context-accessor.test.ts Outdated
Comment thread packages/multitenancy-core/src/types.ts Outdated
Comment thread .changeset/hip-teachers-do.md Outdated
dragos-rosca and others added 3 commits March 20, 2026 12:09
@fraliv13 fraliv13 self-requested a review March 20, 2026 10:10
@dragos-rosca dragos-rosca merged commit 6c440f8 into main Mar 20, 2026
@dragos-rosca dragos-rosca deleted the bugfix/separate-tenant-context-store branch March 20, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants