Skip to content

Starting container testcontaiers throw an error #1035

@MrResor

Description

@MrResor

Expected Behaviour
Container starts properly and the tests are performed

Actual Behaviour
Error is thrown and tests are skipped:

TypeError: Cannot read properties of undefined (reading 'length')
 ❯ node_modules/testcontainers/src/generic-container/inspect-container-util-ports-exposed.ts:27:72
 ❯ common_1.IntervalRetry.retryUntil.message node_modules/testcontainers/src/generic-container/inspect-container-util-ports-exposed.ts:27:10
 ❯ IntervalRetry.retryUntil node_modules/testcontainers/src/common/retry.ts:47:20
 ❯ inspectContainerUntilPortsExposed node_modules/testcontainers/src/generic-container/inspect-container-util-ports-exposed.ts:18:18
 ❯ GenericContainer.startContainer node_modules/testcontainers/src/generic-container/generic-container.ts:205:52

Part of the code that throws said error:

const container = await buildtContainer.withEnvironment({
    POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD,
    PGUSER: process.env.USER_LOGIN,
    PGPASSWORD: process.env.USER_PASSWORD,
    PGPORT: Number(process.env.DB_PORT),
  })
  .withExposedPorts(Number(process.env.DB_PORT))
  .withNetworkMode('host')
  .withWaitStrategy(Wait.forLogMessage('[1] LOG:  database system is ready to accept connections'))
  .start()

Testcontainer Logs
No logs as container has not yet started

Steps to Reproduce
I was running the test using testcontainers and github actionsand i got an uneralated (error about npm having issues with optional dependencies). I followed the instruction to remove node_modules and package-lock.json and reinstalled the dependencies. After that each time i try to run the test both localy and on github action i get the error above. In addition i tried to install the dependencies with -legacy-peer-deps, but result remain unchanged. My understanding of both node.js and testcontainers is quite shallow but my guess is that one of the dependencies is not properly installed and causes issues with the testcontaiers code. All the code run properly unitill latest github actions down period on 5.06

Environment Information

  • Operating System: Ubuntu 24.04.2 LTS
  • Docker Version: 28.2.0, build 879ac3f
  • Node version: 22.16.0
  • Testcontainers version: 11.0.1

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