Skip to content

EPIPE error on Postgres snapshot on Github Actions #969

@PieterJanVdb

Description

@PieterJanVdb

Expected Behaviour
For the snapshot to execute successfully in a Github Actions environment.

Actual Behaviour
When executing await postgresContainer.snapshot(); during CI, it throws an EPIPE error. It works fine locally on my machine (MacOS M1 with Colima)

Testcontainer Logs
(Patched the @testcontainers/postgresql package to have this.exec include { logs: true } to have the log output of exec for this)
(I've redacted the db name)

2025-04-02T11:35:33.864Z testcontainers:containers [800f65a7b637] The files belonging to this database system will be owned by user "postgres".
2025-04-02T11:35:33.864Z testcontainers:containers [800f65a7b637] This user must also own the server process.
2025-04-02T11:35:33.865Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:33.865Z testcontainers:containers [800f65a7b637] The database cluster will be initialized with locale "en_US.utf8".
2025-04-02T11:35:33.865Z testcontainers:containers [800f65a7b637] The default database encoding has accordingly been set to "UTF8".
2025-04-02T11:35:33.865Z testcontainers:containers [800f65a7b637] The default text search configuration will be set to "english".
2025-04-02T11:35:33.865Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:33.865Z testcontainers:containers [800f65a7b637] Data page checksums are disabled.
2025-04-02T11:35:33.865Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:33.865Z testcontainers:containers [800f65a7b637] fixing permissions on existing directory /var/lib/postgresql/data ... ok
2025-04-02T11:35:33.866Z testcontainers:containers [800f65a7b637] creating subdirectories ... ok
2025-04-02T11:35:33.866Z testcontainers:containers [800f65a7b637] selecting dynamic shared memory implementation ... posix
2025-04-02T11:35:33.874Z testcontainers:containers [800f65a7b637] selecting default max_connections ... 100
2025-04-02T11:35:33.889Z testcontainers:containers [800f65a7b637] selecting default shared_buffers ... 128MB
2025-04-02T11:35:33.961Z testcontainers:containers [800f65a7b637] selecting default time zone ... UTC
2025-04-02T11:35:33.963Z testcontainers:containers [800f65a7b637] creating configuration files ... ok
2025-04-02T11:35:34.108Z testcontainers:containers [800f65a7b637] running bootstrap script ... ok
2025-04-02T11:35:34.328Z testcontainers:containers [800f65a7b637] sh: locale: not found
2025-04-02T11:35:34.329Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:34.328 UTC [36] WARNING:  no usable system locales were found
2025-04-02T11:35:34.881Z testcontainers:containers [800f65a7b637] performing post-bootstrap initialization ... ok
2025-04-02T11:35:34.977Z testcontainers:containers [800f65a7b637] syncing data to disk ... ok
2025-04-02T11:35:34.977Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:34.978Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:34.978Z testcontainers:containers [800f65a7b637] Success. You can now start the database server using:
2025-04-02T11:35:34.978Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:34.978Z testcontainers:containers [800f65a7b637] pg_ctl -D /var/lib/postgresql/data -l logfile start
2025-04-02T11:35:34.978Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:34.978Z testcontainers:containers [800f65a7b637] initdb: warning: enabling "trust" authentication for local connections
2025-04-02T11:35:34.978Z testcontainers:containers [800f65a7b637] You can change this by editing pg_hba.conf or using the option -A, or
2025-04-02T11:35:34.978Z testcontainers:containers [800f65a7b637] --auth-local and --auth-host, the next time you run initdb.
2025-04-02T11:35:35.001Z testcontainers:containers [800f65a7b637] waiting for server to start....2025-04-02 11:35:35.001 UTC [53] LOG:  starting PostgreSQL 13.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit
2025-04-02T11:35:35.002Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.002 UTC [53] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-04-02T11:35:35.006Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.006 UTC [54] LOG:  database system was shut down at 2025-04-02 11:35:34 UTC
2025-04-02T11:35:35.009Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.009 UTC [53] LOG:  database system is ready to accept connections
2025-04-02T11:35:35.052Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.051 UTC [67] FATAL:  database "[our db name]" does not exist
2025-04-02T11:35:35.084Z testcontainers:containers [800f65a7b637] done
2025-04-02T11:35:35.084Z testcontainers:containers [800f65a7b637] server started
2025-04-02T11:35:35.156Z testcontainers:containers [800f65a7b637] CREATE DATABASE
2025-04-02T11:35:35.157Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:35.157Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:35.158Z testcontainers:containers [800f65a7b637] /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
2025-04-02T11:35:35.158Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:35.158Z testcontainers:containers [800f65a7b637] waiting for server to shut down....2025-04-02 11:35:35.158 UTC [53] LOG:  received fast shutdown request
2025-04-02T11:35:35.160Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.159 UTC [53] LOG:  aborting any active transactions
2025-04-02T11:35:35.160Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.160 UTC [53] LOG:  background worker "logical replication launcher" (PID 60) exited with exit code 1
2025-04-02T11:35:35.161Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.161 UTC [55] LOG:  shutting down
2025-04-02T11:35:35.171Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.171 UTC [53] LOG:  database system is shut down
2025-04-02T11:35:35.259Z testcontainers:containers [800f65a7b637] done
2025-04-02T11:35:35.259Z testcontainers:containers [800f65a7b637] server stopped
2025-04-02T11:35:35.259Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:35.259Z testcontainers:containers [800f65a7b637] PostgreSQL init process complete; ready for start up.
2025-04-02T11:35:35.259Z testcontainers:containers [800f65a7b637] 
2025-04-02T11:35:35.276Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.275 UTC [1] LOG:  starting PostgreSQL 13.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit
2025-04-02T11:35:35.276Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.275 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2025-04-02T11:35:35.276Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.275 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2025-04-02T11:35:35.277Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.277 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-04-02T11:35:35.280Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.280 UTC [74] LOG:  database system was shut down at 2025-04-02 11:35:35 UTC
2025-04-02T11:35:35.284Z testcontainers:containers [800f65a7b637] 2025-04-02 11:35:35.283 UTC [1] LOG:  database system is ready to accept connections
2025-04-02T11:22:03.368Z testcontainers:exec [1dd5a6b94e09] UPDATE 0

2025-04-02T11:22:03.429Z testcontainers:exec [1dd5a6b94e09] DROP DATABASE

2025-04-02T11:22:03.430Z testcontainers:exec [1dd5a6b94e09] NOTICE:  database "migrated_template" does not exist, skipping

stderr | [test name]
Failed to execute command: CREATE DATABASE "migrated_template" WITH TEMPLATE "[our db name]" OWNER "postgres" Error: write EPIPE
  at afterWriteDispatched (node:internal/stream_base_commons:159:15)
  at writeGeneric (node:internal/stream_base_commons:150:3)
  at Socket._writeGeneric (node:net:971:11)
  at Socket._write (node:net:983:8)
  at doWrite (node:internal/streams/writable:598:12)
  at clearBuffer (node:internal/streams/writable:783:7)
  at onwrite (node:internal/streams/writable:653:7)
  at afterWriteDispatched (node:internal/stream_base_commons:162:9)
  at writeGeneric (node:internal/stream_base_commons:150:3)
  at Socket._writeGeneric (node:net:971:11) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

Steps to Reproduce

  1. In this environment: Github Actions
  2. With this config: nothing to specify here
  3. Run:
const postgresContainer = await new PostgreSqlContainer()
    .withDatabase(config.name)
    .withUsername(config.user)
    .withPassword(config.password)
    .start();

await postgresContainer.snapshot();
  1. See error:
Failed to execute command: CREATE DATABASE "migrated_template" WITH TEMPLATE "[our table name]" OWNER "postgres" Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:159:15)
    at writeGeneric (node:internal/stream_base_commons:150:3)
    at Socket._writeGeneric (node:net:971:11)
    at Socket._write (node:net:983:8)
    at doWrite (node:internal/streams/writable:598:12)
    at clearBuffer (node:internal/streams/writable:783:7)
    at onwrite (node:internal/streams/writable:653:7)
    at afterWriteDispatched (node:internal/stream_base_commons:162:9)
    at writeGeneric (node:internal/stream_base_commons:150:3)
    at Socket._writeGeneric (node:net:971:11) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Environment Information

  • Operating System: ubuntu-latest
  • Docker Version: 24.0.7
  • Node version: 22
  • Testcontainers version: 10.23.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageInvestigation required

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions