Skip to content

[Bug]: ProductEvents.PRODUCT_CATEGORY_DELETED does not trigger subscribers while "product-category.deleted" does #16045

Description

@giladv

What happened?

When registering a Medusa subscriber for product category deletion events, using the exported ProductEvents.PRODUCT_CATEGORY_DELETED constant does not trigger the subscriber, but using the literal event name "product-category.deleted" does.

This is surprising because the exported event constant should be usable anywhere the corresponding literal event name is accepted.

Reproduction

Using Medusa 2.17.2, create a subscriber similar to this:

import type { SubscriberConfig } from "@medusajs/medusa"
import { ProductEvents } from "@medusajs/framework/utils"

export const config: SubscriberConfig = {
  event: [
    ProductEvents.PRODUCT_CATEGORY_DELETED, // does not trigger
    "product-category.deleted", // triggers
  ],
}

Delete a product category.

Expected behavior

A subscriber registered with ProductEvents.PRODUCT_CATEGORY_DELETED should be triggered for the product category deletion event, the same as when registering with the literal "product-category.deleted" event name.

Actual behavior

The subscriber is not triggered when only ProductEvents.PRODUCT_CATEGORY_DELETED is used. Adding "product-category.deleted" to the same subscriber config causes the subscriber to run.

Notes

The Medusa subscriber docs show SubscriberConfig.event accepting event names, including arrays of event names. Since constants such as ProductEvents are exported for these events, ProductEvents.PRODUCT_CATEGORY_DELETED should resolve to the emitted product category deletion event name.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions