Skip to content

chore: update mikro-orm to 6.6.12#15018

Merged
shahednasser merged 6 commits intodevelopfrom
chore/update-mikro-orm
Apr 8, 2026
Merged

chore: update mikro-orm to 6.6.12#15018
shahednasser merged 6 commits intodevelopfrom
chore/update-mikro-orm

Conversation

@shahednasser
Copy link
Copy Markdown
Member

@shahednasser shahednasser commented Apr 6, 2026

Update MikroORM dependencies as a mitigation to the following vulnerabilities:

Issues fixed following the update:

  • We previously accessed subscribers on the entity manager that wasn't publicly accessible, and following the update this caused an error. Latest version has a getSubscribers API to access it.
  • v6.5.0 of Mikro ORM automatically INNER JOINs referenced entities. This causes issues in our code when a referenced entity is soft-deleted, as the INNER JOIN with WHERE deleted_at IS NULL silently excludes the owning entity from query results. For example, a Payment becomes invisible after its PaymentSession is soft-deleted.
    • We fix this by disabling the new autoJoinRefsForFilters option, which reverts the behavior to the v6.4.16 behavior that our code is built on
  • v6.6.0 of MikroORM switched from per-entity-type alias counters to a global sequential counter. This causes issues in our code when hardcoded entity aliases (e.g. "o0") are used in populateWhere raw fragments for SELECT_IN queries, as those aliases no longer reliably refer to the expected entity.
    • The fix uses MikroORM's raw callback in populateWhere conditions, where the alias parameter is resolved to the correct entity alias at query-build time instead of being hardcoded. Additionally, findAndCount was updated to run find and count as separate queries, since the count query uses JOINED strategy internally (with a different alias context) but the version subqueries were built for SELECT_IN aliases.

@shahednasser shahednasser requested a review from a team as a code owner April 6, 2026 10:49
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 6, 2026

🦋 Changeset detected

Latest commit: 687b3d5

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

This PR includes changesets to release 77 packages
Name Type
@medusajs/utils Patch
@medusajs/deps Patch
@medusajs/event-bus-redis Patch
@medusajs/framework Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/workflows-sdk Patch
@medusajs/cli Patch
@medusajs/medusa-oas-cli Patch
integration-tests-http Patch
@medusajs/types Patch
create-medusa-app Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/event-bus-local Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/draft-order Patch
@medusajs/core-flows Patch
@medusajs/oas-github-ci Patch
@medusajs/js-sdk Patch
@medusajs/http-types-generator Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
medusa-dev-cli Patch
@medusajs/ui 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

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

9 Skipped Deployments
Project Deployment Actions Updated (UTC)
api-reference Ignored Ignored Apr 8, 2026 5:55am
api-reference-v2 Ignored Ignored Preview Apr 8, 2026 5:55am
bloom-docs Ignored Ignored Preview Apr 8, 2026 5:55am
cloud-docs Ignored Ignored Preview Apr 8, 2026 5:55am
docs-ui Ignored Ignored Preview Apr 8, 2026 5:55am
docs-v2 Ignored Ignored Preview Apr 8, 2026 5:55am
medusa-docs Ignored Ignored Preview Apr 8, 2026 5:55am
resources-docs Ignored Ignored Preview Apr 8, 2026 5:55am
user-guide Ignored Ignored Preview Apr 8, 2026 5:55am

Request Review

Comment on lines -58 to 61
// There is no public API to unregister subscribers or check if a subscriber is already
// registered. This means that we need to manually check if the subscriber is already
// registered, otherwise we will register the same subscriber twice.
const hasListeners = (manager.getEventManager() as any).subscribers.some(
(s) => s.constructor.name === subscriberInstance.constructor.name
)
const hasListeners = Array.from(
manager.getEventManager().getSubscribers()
).some((s) => s.constructor.name === subscriberInstance.constructor.name)
if (!hasListeners) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reason: subscribers changed from a TypeScript private array to a JS #private Set, which is inacessible by any. However, we can use the getSubscribers public method that returns the set.

Copy link
Copy Markdown
Contributor

@NicolasGorga NicolasGorga left a comment

Choose a reason for hiding this comment

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

LGTM

@shahednasser shahednasser marked this pull request as draft April 6, 2026 13:57
@shahednasser shahednasser marked this pull request as ready for review April 7, 2026 09:00
Comment on lines +116 to +122
// Introduced in MikroORM 6.5.0: when enabled, MikroORM auto-joins referenced entities
// (e.g. INNER JOINs PaymentSession when querying Payment) to apply their global filters
// (e.g. softDeletable). For non-nullable FKs this uses INNER JOIN, silently excluding
// owning entities (e.g. Payment) when the referenced entity (e.g. PaymentSession) is
// soft-deleted. Medusa was designed around MikroORM 6.4.x where this didn't exist, so
// we disable it to preserve the expected behavior.
autoJoinRefsForFilters: false,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this flag was added in v6.0.0, not v6.5

maybe you want to diable just the filters on relations via filtersOnRelations: false instead

https://mikro-orm.io/blog/mikro-orm-6-6-released#more-control-over-filters-on-relations

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for reviewing @B4nan !

Setting filtersOnRelations: false doesn't fix the affected issue. Only autoJoinRefsForFilters: false does. filtersOnRelations: false seems to affect other areas as well where relations aren't being retrieved as expected.

@shahednasser shahednasser changed the title chore: update mikro-orm to 6.6.10 chore: update mikro-orm to 6.6.12 Apr 8, 2026
@shahednasser shahednasser merged commit 62e0760 into develop Apr 8, 2026
38 checks passed
@shahednasser shahednasser deleted the chore/update-mikro-orm branch April 8, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants