Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug]: Redis event bus not triggering events #11633

Open
theskollie opened this issue Feb 26, 2025 · 0 comments
Open

[Bug]: Redis event bus not triggering events #11633

theskollie opened this issue Feb 26, 2025 · 0 comments

Comments

@theskollie
Copy link

theskollie commented Feb 26, 2025

Package.json file

{
  "name": "backend",
  "version": "0.0.1",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "scripts": {
    "build": "medusa build",
    "start": "medusa start",
    "dev": "medusa develop",
  },
  "dependencies": {
    "@medusajs/admin-sdk": "2.5.1",
    "@medusajs/cli": "2.5.1",
    "@medusajs/framework": "2.5.1",
    "@medusajs/medusa": "2.5.1",
    "@mikro-orm/core": "6.4.3",
    "@mikro-orm/knex": "6.4.3",
    "@mikro-orm/migrations": "6.4.3",
    "@mikro-orm/postgresql": "6.4.3",
    "awilix": "^8.0.1",
    "pg": "^8.13.0"
  },
  "devDependencies": {
    "@medusajs/test-utils": "2.5.1",
    "@mikro-orm/cli": "6.4.3",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.13",
    "@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.2",
    "vite": "^5.2.11",
    "yalc": "^1.0.0-pre.53"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

v20.12.1

Database and its version

PostgreSQL 17

Operating system name and version

MacOS

Browser name

Chrome

What happended?

I have a subscriber that triggers based on the product.updated event. When using the Local Event Bus, it triggers as expected. When I deploy to production, I am using the Redis Event Bus.
I have Redis Server using Docker (docker-compose file below) and setup using Medusa Config (file below).
When I launch the Medusa backend, it says the connection to the redis for the event bus was established successfully - But triggering an event does nothing. When I revert to local event bus without any other changes, my subscriber works as expected.

Medusa Config:
module.exports = defineConfig({ projectConfig: { databaseUrl: process.env.DATABASE_URL, http: { storeCors: process.env.STORE_CORS!, adminCors: process.env.ADMIN_CORS!, authCors: process.env.AUTH_CORS!, jwtSecret: process.env.JWT_SECRET || 'supersecret', cookieSecret: process.env.COOKIE_SECRET || 'supersecret', }, redisUrl: process.env.REDIS_URL, }, modules: [ { resolve: '@medusajs/medusa/event-bus-redis', options: { redisUrl: process.env.REDIS_URL, }, }, ], });

Docker Compose
version: '3.8' services: redis: image: redis:7 container_name: redis ports: - '6379:6379'

Subscriber Example:
`import { SubscriberArgs, type SubscriberConfig } from '@medusajs/framework';

export default async function productUpdated({
event,
container,
}: SubscriberArgs) {
const logger = container.resolve('logger');

logger.info('Product Updated!');

console.log(event);
}

export const config: SubscriberConfig = {
event: 'product.updated',
};`

On Launch:
info: Connection to Redis in module 'event-bus-redis' established

Expected behavior

Events should trigger when using Redis Event Bus

Actual behavior

Events not triggering when using Redis Event Bus, but they are triggering when using local event bus

Link to reproduction repo

npx create-medusa-app@latest and just add the same medusa config file for the redis event bus

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

No branches or pull requests

1 participant