Developer Uncovers Silent Fallback in node-pg-migrate That Uses PG* Env Vars
A developer exploring the node-pg-migrate package discovered that omitting the --envPath flag did not trigger the expected database connection error, but instead allowed migrations to run successfully. This happened because the CLI automatically loaded the project's .env file via dotenv, populating the environment with PG* variables such as PGHOST and PGPASSWORD. When DATABASE_URL was found to be empty, the tool fell back to creating a ConnectionParameters object from the pg library, which silently reads those standard PostgreSQL environment variables. The undocumented fallback behavior meant the tool connected to a live Neon cloud database without an explicit connection string being set. The finding highlights the importance of investigating unexpected successes in code, not just failures.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in