Skip to content

[Bug]: medusa db:migrate hangs indefinitely right after creating the mikro_orm_migrations table #15987

Description

@nvdiffusionrun

Package.json file

"name": "nvdiffusion-backend",
  "version": "0.0.1",
  "description": "Backend Medusa v2 de nvdiffusion.com.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "keywords": [
    "sqlite",
    "postgres",
    "typescript",
    "ecommerce",
    "headless",
    "medusa"
  ],
  "scripts": {
    "build": "medusa build",
    "start": "medusa start",
    "dev": "medusa develop",
    "lint": "medusa lint",
    "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=false --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"
  },
  "dependencies": {
    "@medusajs/admin-sdk": "2.17.2",
    "@medusajs/admin-shared": "2.17.2",
    "@medusajs/caching": "2.17.2",
    "@medusajs/cli": "2.17.2",
    "@medusajs/dashboard": "2.17.2",
    "@medusajs/draft-order": "2.17.2",
    "@medusajs/framework": "2.17.2",
    "@medusajs/medusa": "2.17.2",
    "@medusajs/ui": "4.1.19",
    "@tanstack/react-query": "5.64.2",
    "react-i18next": "13.5.0",
    "react-router-dom": "6.30.3",
    "zod": "4.2.0"
  },
  "devDependencies": {
    "@medusajs/test-utils": "2.17.2",
    "@swc/core": "^1.7.28",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.13",
    "@types/node": "^20.12.11",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.4.14",
    "yalc": "^1.0.0-pre.53"
  },
  "engines": {
    "node": ">=20"
  },
  "packageManager": "npm@11.12.1"
}

Node.js version

v22.23.1 (also tested on v22-alpine, same result)

Database and its version

PostgreSQL 16.14

Operating system name and version

Reproduced inside Docker containers: node:22-alpine (musl) and node:22-slim (Debian/glibc). Same hang on both.

Browser name

N/A (backend CLI issue, no browser involved)

What happended?

import { loadEnv, defineConfig } 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,
workerMode: (process.env.MEDUSA_WORKER_MODE || "shared") as "shared" | "worker" | "server",
http: {
storeCors: process.env.STORE_CORS!,
adminCors: process.env.ADMIN_CORS!,
authCors: process.env.AUTH_CORS!,
jwtSecret: process.env.JWT_SECRET,
cookieSecret: process.env.COOKIE_SECRET,
}
}
})

Expected behavior

medusa db:migrate should run all pending migrations and exit, instead of hanging indefinitely

Actual behavior

the command hangs forever right after creating the mikro_orm_migrations table, 0% CPU, no error, no timeout

Link to reproduction repo

https://github.com/nvdiffusionrun/medusa-migrate-hang-repro

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions