Skip to main content

v1.10.0

Version 1.10.0 of Medusa introduces performance improvement related to Typeorm and the removal of the retrieveSubscribers previously added to the event bus service.

Overview

Typeorm Performance Improvement

To improve performance of Cart and Product retrieval, our team has changed the relationLoadStrategy in Typeorm from join to query. This means relations are loaded using separate database queries rather than many joins in a single large query. This change also significantly reduces memory usage, as it will produce a much smaller result set to store in memory.

Unfortunately, Typeorm's query-strategy does not work well in concert with transactions, which is extensively used across our codebase. The separate queries to fetch relations on entities will run outside of an initiated transaction, because it uses a different query runner. This leads to incorrect results in cases where you request entities previously created in an ongoing transaction. Those changes will not have persisted to the database at the time of querying, and will therefore be "invisible" to other query runners.

Instead of compromising on the performance of our API, our team decided to fix the issue in Typeorm, which can be found in this PR on Typeorm's repository. It is still yet to be merged, so, for now, our team has published a forked version of Typeorm that includes the fix. This is the breaking change of this release.

retrieveSubscribers Removal

The retrieveSubscribers was introduced in a previous version to ensure that events are triggered only if a subscriber was listening to that event. However, the approach implemented caused unanticipated issues with the triggering of events.

So, this method has been removed from the event bus service. If you've implemented this event in your custom event bus service, this should cause no issues, but your retrieveSubscribers method will not be used anymore.


How to Update

Run the following command in the root directory of your Medusa Backend to update the core:

npm install @medusajs/medusa@1.10.0

If you are using our local event bus, run the following command to update the event system:

npm install @medusajs/event-bus-local@1.9.1

It's also recommended to update any other Medusa plugins or packages you have installed.


Actions Required

Change Typeorm Package

To make sure your project works as expected, you'll need to use our forked Typeorm version in your project until Typeorm merges our PR and publishes a new version.

In your package.json, replace the Typeorm version with the following:

"typeorm": "npm:@medusajs/typeorm@next"
Was this page helpful?