Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

umzug.up() unstable and throwing ECONNRESET when used in Kubernetes Pod container

Open
#709 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
node.js, postgresql, typescript
Domain
backend, databases

Research direction

The relevant entry points are src/db/db.ts, src/db/config.ts, and src/db/migrate.ts; start by running node ./src/db/migrate.js with the same Kubernetes and PostgreSQL settings. Compare behavior with and without the shown pool configuration and use the reported ECONNRESET as the failure signal. Done should be a reproducible cause and a documented fix or confirmed container guidance.

Written by the indexing model from the issue text.

Description

I'm using Umzug migrations in an app that is deployed to the Kubernetes cluster. There is where I first run the migrations upon the start of the container, before I actually start the app. The migration (or it's connection to the database) is at this point is very unstable. It sometimes (rarely though) works properly right after the deployment, the other times I need to restart the Deployment (Pods) several times and eventually it does connect to the database and executes the migrations.

If I execute the migrations from the same app, but from local computer, the migrations always get executed flawlessly, so it cannot be up to the database that this issues arise.

Mostly I have notice that the migrations are working the worst from a container when I set my own database pool configuration, but also with that I could not pinpoint the problem.

Are there any particular considerations when using the Umzug for migrations in a container?

Umzug version: v3.8.2
Storage: SequelizeStorage
Database: Postgres
Sequelize version: v6.37.7
Node version: v22
Dev setup: Typescript, but it's transpiled to vanilla commonjs when deployed
Execution: "node ./src/db/migrate.js"

My code:

// ./src/db/db.ts
import { DataTypes, Transaction } from "sequelize";
import { Model, Sequelize } from "sequelize-typescript";
import { Umzug, SequelizeStorage } from "umzug";
import * as clsHooked from "cls-hooked";

import { config } from "./config";

// Model for instantiating Sequelize
import { Address, Condition, Document, Header, Partner, Position } from "../models";

export const cls = clsHooked.createNamespace("cls-namespace");

// Only do this if using PostgreSQL
if (config.dialect === "postgres") {
  // @ts-expect-error-next-line
  DataTypes.postgres.DECIMAL.parse = function (value: string) {
    return Number(value);
  };
}

Sequelize.useCLS(cls);

const { database, username, password, ...dbConfig } = config;
export const sql = new Sequelize(database, username, password, {
  ...dbConfig,
  models: [Address, Partner, Header, Position, Condition, Document],
});

export const migrator = new Umzug({
  migrations: {
    glob: ["./migrations/*.{ts,js}", { cwd: __dirname }],
  },
  context: sql.getQueryInterface(),
  storage: new SequelizeStorage({
    sequelize: sql,
    modelName: "x_migrator_meta",
  }),
  logger: console,
});
// ./src/db/config.ts
import { SequelizeOptions } from "sequelize-typescript";
// import * as env from "../env";

export const config = {
  username: process.env.DB_USER || "postgres",
  password: process.env.DB_PASSWORD || "supersecret",
  database: process.env.DB_NAME || "postgres",
  host: process.env.DB_HOST || "localhost",
  port: Number(process.env.DB_PORT) || 5432,
  dialect: "postgres" as SequelizeOptions["dialect"],
  dialectOptions: {
    ssl: Boolean(process.env.SSL_MODE === "true" || process.env.SSL_MODE === "require"),
    useNativeUUID: true,
  },
  // pool: {
  //   min: Number(env.get("DB_POOL_MIN_CONNECTIONS")),
  //   max: Number(env.get("DB_POOL_MAX_CONNECTIONS")),
  //   acquire: Number(env.get("DB_POOL_ACQUIRE_IN_MS")),
  //   idle: Number(env.get("DB_POOL_IDLE_IN_MS")),
  // },
  logging: process.env.DB_VERBOSE === "true",
  minifyAliases: true,
  migrationStorageTableSchema: "sales_orders",
  schema: "sales_orders",
};
// ./src/db/migrate.ts
import { migrator } from "./db";
migrator.runAsCLI().finally(() => process.exit(0)); // process.exit(0) because otherwise it exits with code 1 when error occurs
Dominant language
TypeScript
Stars
2.2k
Forks
162
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sequelize/umzug

All issues in sequelize/umzug

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.