6 months ago
I recently uploaded a server hosting medusa v2.1 to medusa v2.5, which worked fine.
I then changed the value of a variable and since then the server keeps crashing. I reverted the variable change to be in the same state as before without solving the problem.
The server keeps trying to migrate the db but encounters this error:
> medusa-starter-default@0.0.1 predeploy
> medusa db:migrate redisUrl not found. A fake redis instance will be used. Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?£
The interesting thing is that I have a staging environment running in parallel with the same code without any issue.
Any idea what it could be? Many thanks for the help! [View Deploy details](https://railway.com/project/70001676-7040-44c5-b0e7-424e37a47dfc/service/af53bb4e-628b-486e-b499-40ba9da0b2c5?id=4ed3e095-ff18-49b9-81dc-614d45d15603) > ⓘ Deployment information is only viewable by project members and Railway employees.
14 Replies
6 months ago
Hi, I can see that the value of your REDIS_URL in your medusa-server on production doesn't match the value of the REDIS_URL of your medusa-redis service?
Can you delete and reference the variable again?
Status changed to Awaiting User Response Railway • 6 months ago
6 months ago
Hello, Thank you very much for the quick reply!
I double checked and they seem to be the same from my side. Just to be sure, I changed them to be references: REDIS_URL="${{medusa-redis.REDIS_PUBLIC_URL}}"
However, the problem persists.
Status changed to Awaiting Railway Response Railway • 6 months ago
6 months ago
Seems medusa `db:migrate` might not be calling any redis url at all. Please can you check your code. How are you handling/calling the redis url env in that command?
Status changed to Awaiting User Response Railway • 6 months ago
6 months ago
You pointed me in the right direction, there was an issue with the config file indeed, but it seems that the "full pool" issue isn't related and the code was working earlier even without redis. Now I get this error:
> medusa-starter-default@0.0.1 predeploy
> medusa db:migrate
Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
npm warn config production Use --omit=dev
instead.
Here is the current medusa-config.ts file:import { defineConfig, loadEnv } from "@medusajs/framework/utils"
loadEnv(process.env.NODE_ENV || "development", process.cwd())
module.exports = defineConfig({
projectConfig: {
databaseUrl: process.env.DATABASE_URL,
redisUrl: process.env.REDIS_URL,
databaseDriverOptions: {
connection: {
ssl: {
rejectUnauthorized: false,
},
},
},
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",
},
workerMode: process.env.MEDUSA_WORKER_MODE as
| "shared"
| "worker"
| "server",
},
modules: [
{
resolve: "@medusajs/medusa/cache-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
{
resolve: "@medusajs/medusa/event-bus-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
{
resolve: "@medusajs/medusa/workflow-engine-redis",
options: {
redis: {
url: process.env.REDIS_URL,
},
},
},
],
})
I recently updated the dependencies of medusa to v2.5.0 and mikro-orm to v6.4.3. Here's the package.json/{
"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": {
"seed": "medusa exec ./src/scripts/seed.ts",
"build": "medusa build",
"predeploy": "medusa db:migrate",
"migrations": "medusa db:migrate",
"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": "^2.5.0",
"@medusajs/cli": "^2.5.0",
"@medusajs/framework": "^2.5.0",
"@medusajs/medusa": "^2.5.0",
"@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": "latest",
"@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"
},
"engines": {
"node": ">=20"
},
"packageManager": "yarn@4.5.3+sha512.3003a14012e2987072d244c720506549c1aab73ee728208f1b2580a9fd67b92d61ba6b08fe93f6dce68fd771e3af1e59a0afa28dd242dd0940d73b95fedd4e90"
}
Status changed to Awaiting Railway Response Railway • 6 months ago
6 months ago
Another information, everything starts correctly in my staging environment, which is connected to the same branch:
MODULE: file
Skipped. Database is up-to-date for module.
MODULE: file
Skipped. Database is up-to-date for module.
MODULE: file
Skipped. Database is up-to-date for module.
MODULE: fulfillment
Skipped. Database is up-to-date for module.
MODULE: fulfillment
Skipped. Database is up-to-date for module.
MODULE: fulfillment
Skipped. Database is up-to-date for module.
MODULE: notification
Skipped. Database is up-to-date for module.
MODULE: notification
Skipped. Database is up-to-date for module.
MODULE: notification
Skipped. Database is up-to-date for module.
Migrations completed
Syncing links...
Database already up-to-date
No link to load from /app/.medusa/server/src/links. skipped.
Connection to Redis in module 'cache-redis' established
Connection to Redis in module 'event-bus-redis' established
Connection to Redis in module 'workflow-engine-redis' established
Connection to Redis PubSub in module 'workflow-engine-redis' established
Locking module: Using "in-memory" as default.
No pending migration scripts to execute
npm warn config production Use --omit=dev
instead.
> medusa-starter-default@0.0.1 start
> medusa start
Skipping instrumentation registration. No register function found.
No link to load from /app/.medusa/server/src/links. skipped.
Connection to Redis in module 'cache-redis' established
Connection to Redis in module 'event-bus-redis' established
Connection to Redis in module 'workflow-engine-redis' established
Connection to Redis PubSub in module 'workflow-engine-redis' established
Locking module: Using "in-memory" as default.
Creating server
Server is ready on http://localhost:9000
6 months ago
Can you duplicate it into another environment to see if it works properly as well?
Status changed to Awaiting User Response Railway • 6 months ago
6 months ago
Sure, I just tried and it doesn't
Status changed to Awaiting Railway Response Railway • 6 months ago
6 months ago
Status changed to Awaiting User Response Railway • 6 months ago
6 months ago
I'm not entirely sure how to implement your suggestion. Medusa’s built-in Redis integrations expect a Redis Url string, not an instance of ioredis. So I simply added "?family=0" at the end of the REDIS_PUBLIC_URL, but it didn't help unfortunately.
Status changed to Awaiting Railway Response Railway • 6 months ago
6 months ago
Maybe you can point me to a reproducible repo example where I can check this later.
Status changed to Awaiting User Response Railway • 6 months ago
6 months ago
There you go: https://github.com/tevarg/mekanika-medusa-railway
Thank you again for the help!
Status changed to Awaiting Railway Response Railway • 6 months ago
6 months ago
I can see your DATABASE_URL is set to the redis url. Why is that?
Status changed to Awaiting User Response Railway • 6 months ago
6 months ago
Oh wow, many apologies for this long conversation that ended up with such a stupid error... I guess a bad copy paste happened at some point and I really didn't see it! The db url was correct in staging, which explains why it was working with the same code but not in two different environments. Thank you for your patience and your help
Status changed to Awaiting Railway Response Railway • 6 months ago
6 months ago
You are welcome
Status changed to Awaiting User Response Railway • 6 months ago
Status changed to Solved unicodeveloper • 6 months ago