Highlights
Cart-completion strategy response
🚧 Breaking change
Attempting to complete an already completed cart will no longer return a 409 conflict. Instead, the order or swap associated with the completed cart is returned.
More specifically, the response will take one of the following two shapes:
// completing a regular cart
{
response_code: 200,
response_body: { data: order, type: "order" },
}
// completing a swap cart
{
response_code: 200,
response_body: { data: swap, type: "swap" },
}
node-redis
replaced with ioredis
for session management
🚧 Important change
Our default Express session store has been changed from node-redis
to ioredis
.
This was done in response to a request for higher configurability of the Redis client used for session management. It was decided to not only expose more options but simultaneously change the library to ioredis
to be consistent with other packages that use Redis, e.g. the Redis Event Bus + Redis Cache.
Add to cart performance improvements
The add-to-cart endpoint, POST /store/carts/:id/line-items
, has been refactored, improving performance and transaction management. The latter was done in response to some users experiencing issues with concurrent requests leading to database conflicts. The changes to transaction management in the endpoint should significantly reduce the risk of this issue occurring while improving performance.
Some rough benchmarks show that for 1000 requests (10-20/s), we see approx. 30% of requests fail due to database conflicts in the latest version. With this PR, 0% of requests fail – even under a higher load.
New cluster command added to @medusajs/medusa-cli
A new cluster command has been added to our CLI, @medusajs/medusa-cli
:
medusa start-cluster --cpus 3
The command allows you to start Medusa in cluster mode. By default, cluster mode will try to consume all available CPUs for Medusa instances. You can specify the number of CPUs with a CLI argument --cpus
.
Running in cluster mode will likely significantly improve performance as the workload and tasks are distributed among all available instances instead of a single one.
Retry support in medusa-react
🚧 Important change
You can now specify maxRetries
as a prop to the MedusaProvider
from medusa-react
. This config is passed on to the underlying medusa-js
client, which means failed requests are retried the amount of times specified by the param. If not provided, the maxRetries
defaults to 3.
import { MedusaProvider as Provider } from "medusa-react"
import { queryClient } from "../constants/query-client"
export const MedusaProvider = ({ children }) => {
return (
<Provider
queryClientProviderProps={{
client: queryClient,
}}
baseUrl={process.env.MEDUSA_BACKEND_URL}
maxRetries={2}
>
{children}
</Provider>
)
}
Features
- feat(link-modules, pricing, product, utils): Should be able to set some custom database config even in shared mode by @adrien2p in #5755
- feat(medusa): Respond with order when cart is already completed by @olivermrbl in #5766
- feat(medusa-cli): add monorepo support command develop by @driver005 in #5723
- feat(admin): Add Korean language support by @iweurman in #5769
- feat(medusa-payment-klarna): Add language variable by @edinskeja in #4483
- feat(medusa): Improve add line item to cart perf and transaction management + clustering start command by @adrien2p in #5701
- feat(medusa): Replace Node Redis with ioredis by @pepijn-vanvlaanderen in #5656
- feat(core-flows,pricing,medusa,pricing,types,utils): Price List Prices can have their own rules by @riqwan in #5752
- feat(medusa): Emit "discount.created" event when discount is created by @Arsenalist in #5816
- feat(orchestration,core-flows,medusa,product,types,utils): product import/export uses workflows by @riqwan in #5811
- feat(medusa, core-workflows, product): slightly improve create cart workflow by @adrien2p in #5725
- feat(admin-ui): metadata for categories in admin ui and refactor to react-hook-form by @luluhoc in #5697
Bugs
- fix(medusa): throw proper error when product doesn't exist w/ key header by @pKorsholm in #5745
- fix(modules-sdk): add graphql dependency to modules-sdk by @riqwan in #5750
- fix(medusa-react): Allow setting maxRetries on MedusaProvider by @kasperkristensen in #5765
- fix(ui): Bump cva and minor type fixes by @kasperkristensen in #5818
- fix(admin-ui): Bulk editor default fields by @kasperkristensen in #5829
- fix(medusa): Updating note doesn't require loading author relationship by @josetr in #5825
- fix(medusa): Product option values in CSV Export by @mortenengel in #5781
- fix(medusa): Order edit confirmation conflict line items update by @adrien2p in #5867
Docs
- docs: fix back link in Workflows API Reference by @shahednasser in #5740
- docs: updated user guide for product pricing by @shahednasser in #5744
- docs: fix back links for modules references by @shahednasser in #5747
- docs: updated next.js starter docs by @shahednasser in #5748
- docs: update pricing module docs with the latest changes by @riqwan in #5749
- docs: fix typo in onboarding by @shahednasser in #5802
- docs: search results template needs the product ids to fetch previews by @chrislaai in #5793
- docs: enhance how references are generated by @shahednasser in #5805
- docs: update algolia plugin next.js details by @shahednasser in #5807
- docs: added examples for modules usage in Medusa by @shahednasser in #5753
- docs: diagrams plugin tooling by @shahednasser in #5741
- docs: updated Next.js deployment guide by @shahednasser in #5756
- docs: TSDoc + reference of fulfillment by @shahednasser in #5761
- docs: added "Integrate Your Ecommerce Stack" recipe by @shahednasser in #5774
- docs(plugins): puts local-file plugin into correct category in site by @annikorp in #5804
- docs: update local events module to fix mistyped reference to redis events module by @ishaqkhattana in #5835
- docs: Fix multiple typos in medusa docs by @Sajarin-M in #5854
- docs: fixed sidebar in API reference by @shahednasser in #5871
- docs: update required Node.js version for Next.js starter by @shahednasser in #5859
- docs: generate documentation for UI components by @shahednasser in #5849
Chores
- chore(): Add engines to all package.json if needed by @adrien2p in #5812
- chore(medusa): Prefer logger instead of console.log by @adrien2p in #5846
New Contributors
- @driver005 made their first contribution in #5723
- @iweurman made their first contribution in #5769
- @chrislaai made their first contribution in #5793
- @annikorp made their first contribution in #5804
- @luluhoc made their first contribution in #5697
- @ishaqkhattana made their first contribution in #5835
- @Arsenalist made their first contribution in #5816
- @Sajarin-M made their first contribution in #5854
Full Changelog: v1.18.1...v1.19.0