Exec wait never settles when the Docker stream closes without ending, and Node exits 0
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- docker, node.js, typescript
调研方向
找到 DockerContainerClient.waitForExecStreamToEnd,issue指出它只等待流的end或error事件。首先追踪调用它的监听端口检查,并了解exec.inspect()如何处理退出代码。当流关闭后等待结束,且未完成的检查会持续重试直到启动超时,即为完成。
由索引模型根据 Issue 内容生成。
描述
Expected Behaviour
PostgreSqlContainer.start() resolves, or rejects with an error, when the listening-port check's docker exec stream closes.
Actual Behaviour
Sometimes the internal port check never finishes. DockerContainerClient.waitForExecStreamToEnd waits for the exec stream's end or error event only. When the stream emits close without end, that promise never settles. With nothing else keeping the event loop alive, Node exits with code 0, so a Vitest global setup that starts the container ends the whole run with code 0 before any test runs.
It happened in 3 of 12 CI jobs on one runner provider and none on another. Listening for close too (stream.on("close", res)) fixed it in 12 of 12 jobs. exec.inspect() then reports the exit code, and an unfinished check is retried until the startup timeout.
Testcontainers Logs
The last lines for the Postgres container in a failing job. Nothing follows Health check wait strategy complete, and Internal port 5432/tcp ready is never logged:
testcontainers [DEBUG] [d9f4513e9ba1] Waiting for container to be ready...
testcontainers [DEBUG] [d9f4513e9ba1] Waiting for host port 32772...
testcontainers [DEBUG] [d9f4513e9ba1] Waiting for internal port 5432/tcp...
testcontainers [DEBUG] [d9f4513e9ba1] Host port 32772 ready
testcontainers [DEBUG] [d9f4513e9ba1] Host port wait strategy complete
testcontainers [DEBUG] [d9f4513e9ba1] Health check wait strategy complete
A beforeExit listener showed the event loop draining with only stdio pipes left: beforeExit code=0 active=["PipeWrap","PipeWrap","PipeWrap"]. Nothing called process.exit.
Steps to Reproduce
- Start a
PostgreSqlContainerwith the default wait strategy (health check plus listening ports) in a VitestglobalSetup. - Run it repeatedly on a CI runner whose Docker daemon sometimes closes exec streams without ending them. We saw it on Docker Engine 29.7.2 (API 1.55).
- Some runs exit 0 right after
Health check wait strategy complete, without running any tests.
Environment Information
- Operating System: Ubuntu 24.04 (CI runner VM)
- Container runtime and version: Docker Engine 29.7.2, API 1.55
- Node version: 26.14.0
- Test runner and version: Vitest 5.1.2, ESM
- Testcontainers version: 12.2.2,
@testcontainers/postgresql12.2.2, imageghcr.io/baosystems/postgis:18-3.6 - Last Testcontainers version where this worked, if any: unknown
- 主要语言
- TypeScript
- 星标
- 2.7k
- 派生
- 290
- 平均合并
- 4 天 1 小时
- 30 天内合并 PR
- 22
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testcontainers/testcontainers-node 的其他 Issue
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 74/100
testcontainers/testcontainers-node#1539 ·
维护者通常 4 天内回复
-
Let `Wait.forListeningPorts()` wait on specific ports可能已有人在做 @artbom 于 29 天前认领。 未关闭enhancement minor
难度 2/5 1-3 小时 新手友好度 82/100
testcontainers/testcontainers-node#1533 ·
维护者通常 4 天内回复
-
enhancement minor
难度 2/5 1-3 小时 新手友好度 77/100
testcontainers/testcontainers-node#1531 ·
维护者通常 4 天内回复
-
Export the types used in public method signatures可能已有人在做 @artbom 于 29 天前认领。 未关闭enhancement minor
难度 2/5 1-3 小时 新手友好度 78/100
testcontainers/testcontainers-node#1528 ·
维护者通常 4 天内回复
-
A consumer passed to withLogConsumer receives no logs after restart()可能已有人在做 @yabdelhamed 于 11 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 65/100
testcontainers/testcontainers-node#1663 ·
维护者通常 4 天内回复
查看 testcontainers/testcontainers-node 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
earendil-works/gondolin#222 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
endora-commerce/endora-commerce#2203 ·
维护者通常 1 天内回复
-
enhancement priority:medium ready-for-human
难度 2/5 1-3 小时 新手友好度 66/100
wondermoney/wondermoney#1079 ·
维护者通常 1 天内回复