
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
docker-await-postgres
Advanced tools
Start
postgresdocker container and wait until it is truly ready.
This module is heavily inspired by ava-fixture-docker-db.
But unlike the mentioned module, it is
Especially, the later will help when writing integration tests.
The official postgres container loads and executes SQL scripts to create an initial table layout when the container is started, followed by a reboot of the postgres server. This is a welcome feature and a best practice when using docker to host your database. Sadly, it makes it harder to use the image when writing integration tests for your database.
Usually, tests run fast and don't wait the µ-seconds until the postgres server has rebooted. This causes tests to randomly break and connection errors, because the postgres server will just kill all connections when it is rebooting.
Using the Docker API (via dockerode or similar) will only tell you if the container is ready, but not if services inside the container are ready
(you can read more about this here: docker-library/postgres/#146).
docker-await-postgres will read the server logs and long poll until the postgres server is trulry ready. So that tests only run when
the server is trurly ready to accept connections.
Start postgres docker container and wait until it is truly ready.
import { Client } from 'pg';
import { startPostgresContainer } from 'docker-await-postgres';
// Start the container
const config = {
user: 'admin',
password: '12345',
database: 'database',
image: 'postgres',
};
const { stop, port } = await startPostgresContainer(config);
// Connect to the container
const client = new Client({
host: 'localhost',
port,
...config,
});
await client.connect();
const { rows } = await client.query('SELECT NOW()');
await client.end();
// Stop the container
await stop();
FAQs
wait until postgres container is started ... for real
We found that docker-await-postgres demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.