karanchugh02 / medusa-events-webhooks

4 stars 1 forks source link

Error when processing webhook events: eventName is undefined #2

Open sokolovskyio opened 2 months ago

sokolovskyio commented 2 months ago

I installed the medusa-events-webhooks plugin for MedusaJS and followed the documentation precisely. After installation, a new configuration option for webhooks appeared in the admin panel. I added my webhook and started performing actions with an order.

However, I encountered an error when processing the order.canceled event:

An error occurred while processing order.canceled: TypeError: Cannot read properties of undefined (reading 'split').

After debugging, I noticed that in the eventsWebhookHandler method, the eventName field in the arguments is undefined.

I am using the latest version of both the plugin and MedusaJS.

Steps to Reproduce:

Install the medusa-events-webhooks plugin. Configure a webhook in the admin panel. Perform actions with an order that triggers the order.canceled event. Observe the error in the logs. Expected Behavior: The order.canceled event should be processed without errors, and the eventName should have the correct value.

Actual Behavior: The eventName field is undefined, causing a TypeError.

Environment:

MedusaJS version: [latest] Plugin version: [latest] Additional Context: Please investigate why the eventName is undefined in the eventsWebhookHandler method and suggest a possible fix.

"dependencies": {
    "@medusajs/admin": "latest",
    "@medusajs/cache-inmemory": "latest",
    "@medusajs/cache-redis": "latest",
    "@medusajs/event-bus-local": "latest",
    "@medusajs/event-bus-redis": "latest",
    "@medusajs/file-local": "latest",
    "@medusajs/medusa": "latest",
    "@tanstack/react-query": "4.22.0",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv": "16.3.1",
    "express": "^4.17.2",
    "medusa-events-webhooks": "latest",
    "medusa-fulfillment-manual": "latest",
    "medusa-interfaces": "latest",
    "medusa-payment-manual": "latest",
    "medusa-payment-stripe": "latest",
    "prism-react-renderer": "^2.0.4",
    "typeorm": "^0.3.16"
  },
{
    resolve: `medusa-events-webhooks`,
    options: {
      enableUI: true,
      TOKEN_SECRET: process.env.TOKEN_SECRET,
      MAX_RETRY_COUNT: process.env.MAX_RETRY_COUNT,
    },
  }
karanchugh02 commented 2 months ago

@sokolovskyio you need to enable redis event bus. I have faced the same issue earlier.

sokolovskyio commented 2 months ago

@karanchugh02 now i got an error in logs about info: Processing product-variant.updated which has 0 subscribers info: Processing order.canceled which has 1 subscribers warn: An error occurred while processing order.canceled: EntityPropertyNotFoundError: Property "store" was not found in "Order". Make sure your query is correct. warn: One or more subscribers of order.canceled failed. Retrying is not configured. Use 'attempts' option when emitting events.

karanchugh02 commented 2 months ago

Please update to the latest version and try once. Just fixed the query for that.

sokolovskyio commented 2 months ago

@karanchugh02 Please add the handle webhook event order-edit.updated and other events with order-edit

karanchugh02 commented 2 months ago

@sokolovskyio I'll have to work on creating data parsers for the same, will update.