Skip to content
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]: Subscriber is not working #10848

Open
Buudc99 opened this issue Jan 7, 2025 · 7 comments
Open

[Bug]: Subscriber is not working #10848

Buudc99 opened this issue Jan 7, 2025 · 7 comments

Comments

@Buudc99
Copy link

Buudc99 commented Jan 7, 2025

Package.json file

{
  "name": "medusa-starter-default",
  "version": "0.0.1",
  "description": "A starter for Medusa projects.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "keywords": [
    "sqlite",
    "postgres",
    "typescript",
    "ecommerce",
    "headless",
    "medusa"
  ],
  "scripts": {
    "predeploy": "medusa db:migrate",
    "build": "medusa build",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "start": "medusa start",
    "dev": "medusa develop",
    "test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"
  },
  "dependencies": {
    "@medusajs/admin-sdk": "latest",
    "@medusajs/cli": "latest",
    "@medusajs/framework": "latest",
    "@medusajs/js-sdk": "^2.1.3",
    "@medusajs/medusa": "latest",
    "@medusajs/types": "^2.1.3",
    "@mikro-orm/core": "5.9.7",
    "@mikro-orm/knex": "5.9.7",
    "@mikro-orm/migrations": "5.9.7",
    "@mikro-orm/postgresql": "5.9.7",
    "@novu/node": "^2.0.6",
    "@supabase/supabase-js": "^2.47.10",
    "@types/bull": "^3.15.9",
    "ably": "^2.6.0",
    "awilix": "^8.0.1",
    "bull": "^4.16.4",
    "crypto-js": "^4.2.0",
    "js-base64": "^3.7.7",
    "meilisearch": "^0.47.0",
    "pg": "^8.13.0"
  },
  "devDependencies": {
    "@medusajs/test-utils": "latest",
    "@mikro-orm/cli": "5.9.7",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.13",
    "@types/js-base64": "^3.0.0",
    "@types/jsonwebtoken": "^9.0.7",
    "@types/node": "^20.0.0",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.3",
    "vite": "^5.2.11"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

v20.17.0

Database and its version

16.2

Operating system name and version

macos sonoma Version 14.5 (23F79)

Browser name

Chrome

What happended?

Hello development team, I am currently having an issue with the subscriber. It is no longer working, and I don't know the cause. This has become necessary when resetting the password for customers who need the subscriber to get the token. Please respond to me.
Screenshot 2025-01-07 at 08 46 56

Expected behavior

When starting up, it usually loads the events in the src/subscriber directory. Currently, I need to use it to generate a password reset token.

Actual behavior

Contrary to expectations, the subscriber could not be loaded and this caused it to not function.

Link to reproduction repo

https://github.com/Buudc99/medusa-subscriber-not-working.git

@uthng
Copy link

uthng commented Jan 8, 2025

Hi,

The subscribers are loaded but It does not catch auth.password_reset event anymore.

I did other tests with cart.updated. It seems working partially. When a new item is added to the cart, it got the event. But when we change the quantity or remove the item from the cart, it did not catch.

I do not know if these concern the same bug.
I used local event bus and my version medusa is 2.2

Thanks for your helps.

@maselious
Copy link

Same issue most of events are not captured, v2.2. I have even recreated the workflow locally and tried emitting events manually and they still not working. I tried with fulfillment.created

@sheikhumar93
Copy link

Same issue here with v2.2, with the event-bus-redis, events are being added to Redis, but no operation or logs are shown. I tried with product.created, product.updated, order.placed

@maselious
Copy link

Same issue here with v2.2, with the event-bus-redis, events are being added to Redis, but no operation or logs are shown. I tried with product.created, product.updated, order.placed

Is it a redis provider issue? I havent tested with local, will try.

For the full process from creating a cart and placing an order, only SomehtingLink.attached and order.placed events are occured only. Nor cart.created, cart.updated, paymnent_collection.created/initiated (or how it is called)

@sheikhumar93
Copy link

sheikhumar93 commented Jan 13, 2025

@maselious I figured it out by removing workerMode from my medusa-config.ts file. It was set to server. I suppose, when workerMode is server that "worker" wont process any subscribers. Works now on both local and production (using Railway)

Its mentioned here: https://docs.medusajs.com/v1/development/worker-mode

Anyone who is deploying only one instance of Medusa needs to set it to shared mode, so that one server can serve APIs as well as all the rest of the functionality

@uthng
Copy link

uthng commented Jan 13, 2025 via email

@Buudc99
Copy link
Author

Buudc99 commented Jan 14, 2025

@maselious I figured it out by removing workerMode from my medusa-config.ts file. It was set to server. I suppose, when workerMode is server that "worker" wont process any subscribers. Works now on both local and production (using Railway)

Thank you for adjusting it to "shared" then it worked, but it still doesn't function with "server." Nevertheless, it's a step forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants