-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Inventory updates do not emit Events, preventing Cache Revalidation #11691
Comments
Hey @RadzioN, we seem to be emitting events here - https://github.com/medusajs/medusa/blob/develop/packages/modules/inventory/src/services/inventory-module.ts#L581-L590 General format is Does that not work for you? |
Hey @riqwan , unfortunately, it doesn’t work for me. I need the revalidation to trigger after updating stock levels via Product -> Variants -> Edit Stock Levels, but my subscriber isn’t receiving response from your suggestion event
Additionally: There is no such event listed in the Medusa Events Reference. By the way, I’d really appreciate some help with issue #11635 . Even while testing your suggestion, I found this issue quite frustrating - it forces me to manually adjust CSS in Chrome DevTools to proceed with debugging. Thanks in advance for any insights! |
Let me take a look at these events. In the meantime, you want to give a shot opening a PR for the scroll bug? |
This might be related to #11704 I noticed this entity updated event is a general hook. Perhaps this is a more broad issue then just
|
Hey @riqwan , I’ve created a pull request to fix the scroll bug. I used the same approach you applied in product-prices. |
Package.json file
Node.js version
v22.12.0
Database and its version
PostgreSQL 16
Operating system name and version
Windows 11
Browser name
Chrome
What happended?
Inventory updates (e.g., stock level changes) do not emit any events in Medusa. This prevents external services - such as a Next.js storefront using incremental static regeneration (ISR) - from revalidating product pages based on inventory changes.
Currently, Medusa emits events for updates to products and variants, but inventory workflows do not trigger any event emissions. As a result, any storefront relying on Medusa for inventory updates has no way to revalidate cache dynamically when stock levels change.
I’ve verified that:
This issue originates from #11679, where cache revalidation for inventory changes was discussed.
Expected behavior
When an inventory update occurs (e.g., stock level changes due to an order or manual adjustment in the admin panel), Medusa should emit an event such as inventory.updated or stock.level.changed. This would allow external services to listen for these changes and trigger necessary actions, such as cache revalidation.
Actual behavior
Currently, no events are emitted for inventory updates, preventing real-time cache updates and requiring workarounds like polling or no-store fetch strategies in Next.js storefronts.
Link to reproduction repo
npx create-medusa-app@latest
The text was updated successfully, but these errors were encountered: