node.jsredisioredisrailwaymedusajs

Failure connecting Redis service to backend service Railway Medusa.js


I'm deploying Medusa.js application and trying to connect Redis to my backend service.

When I use the variable "Redis.REDIS_URL" I get the following error:

[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis.railway.internal
`
I tried append "?family=0", and edited the server to add [::] before the port like the following:
`
app.listen(port, '::', () => {
    console.log(`Server listening on [::]${port}`);
});

as mentioned on the Private networking documentation page. I also did some research and found another possible solution where I append "?family=6" instead of "?family=0" as mentioned in the docs and both solutions didn't work for me. Currently, I check my log and I see that connection to redis, event-bus-redis, and redis-cache are established, but I'm getting a series of errors related to BullMQ and how it's configured. For the record, I haven't edited BullMQ options in the event-but-redis config. I followed the docs on how to install event-bus-redis and left everything as the default. After researching I think it's mostly because of Redis configuration which affects event-bus-redis as a consequence. Below are some errors from the long list of error I have in my log.

level:
"error"
stack:
[ ]
0:
{ }
columnNumber:19
fileName:"/app/node_modules/bullmq/dist/cjs/classes/queue-base.js"
functionName:"new QueueBase"
lineNumber:36
methodName:null
native:false
typeName:null

1:
{ }
columnNumber:9
fileName:"/app/node_modules/bullmq/dist/cjs/classes/queue.js"
functionName:"new Queue"
lineNumber:18
methodName:null
native:false
typeName:null

2:{ }
columnNumber:27
fileName:"/app/node_modules/@medusajs/medusa/dist/services/job-scheduler.js"
functionName:"new JobSchedulerService"
lineNumber:122
methodName:null
native:false
typeName:null

Solution

  • After a long time of debugging the issue it turned out to be something related to one of Medusajs previous releases where the scheduled-jobs:queue was the name of the queue in BullMQ, which is a dependency package built in event-bus-redis and the issue was fixed by changing scheduled-jobs:queue to scheduled-jobs-queue by one of Medusa contributors, this is due to the BullMQ v5.12.12 update that throws an error whenever a Queue has a semicolon in its name. You can find the issue here If anyone runs into this issue in the future fix the issue by upgrading to Medusa version 1.20.10 which includes the new changes that address this issue. Run the following command.

    npm install @medusajs/medusa@1.20.10