Repository navigation
test(node): Log slow and failed Docker Compose starts in integration tests #25278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JPeer264
merged 1 commit into
jp/flaky-node-should-exit
from
jp/flaky-docker-compose-start
Oct 14, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,4 @@ services: | |
| interval: 2s | ||
| timeout: 3s | ||
| retries: 30 | ||
| start_period: 20s | ||
| start_period: 60s | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,8 @@ import { afterAll, beforeAll, describe } from 'vitest'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type DefineTests = () => void; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const SLOW_START_MS = 60_000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface DockerOptions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * The working directory to run docker compose in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -94,9 +96,28 @@ async function runDockerCompose(options: DockerOptions): Promise<VoidFunction> { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const output = (result: ReturnType<typeof spawnSync>): string => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `${result.stderr?.toString() ?? ''}${result.stdout?.toString() ?? ''}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Surface container logs to make healthcheck failures easier to diagnose in CI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const containerLogs = (): string => spawnSync('docker', composeArgs('logs'), { cwd }).stdout?.toString() ?? ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ensure we're starting fresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| close(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Pull on its own, so a slow image pull on a runner without cached images can be told apart from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // a slow container start. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pullStartedAt = Date.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pull = spawnSync('docker', composeArgs('pull', '--policy', 'missing', '--quiet'), { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cwd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stdio: process.env.DEBUG ? 'inherit' : 'pipe', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pullMs = Date.now() - pullStartedAt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pull.status !== 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // `up` pulls missing images too, so only report this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line no-console | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn(`[docker compose] pull failed after ${pullMs}ms (exit ${pull.status}) in ${cwd}\n${output(pull)}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const composeUp = (): ReturnType<typeof spawnSync> => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| spawnSync('docker', composeArgs('up', '-d', '--wait'), { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cwd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -108,22 +129,33 @@ async function runDockerCompose(options: DockerOptions): Promise<VoidFunction> { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // found" right after the network was created). A clean teardown plus retry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // clears these, while genuine healthcheck failures stay red on every attempt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const maxAttempts = 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const upStartedAt = Date.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let attemptStartedAt = upStartedAt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let result = composeUp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (let attempt = 1; attempt < maxAttempts && result.status !== 0; attempt++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line no-console | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `[docker compose] up --wait attempt ${attempt} failed after ${Date.now() - attemptStartedAt}ms ` + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `(exit ${result.status}) in ${cwd}\n${output(result)}\n--- container logs ---\n${containerLogs()}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| close(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attemptStartedAt = Date.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = composeUp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const upMs = Date.now() - upStartedAt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
131
to
+145
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
just a suggestion, I think this is a bit nicer to read and understand because it demonstrates the flow a bit better but no strong opinions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (result.status !== 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const stderr = result.stderr?.toString() ?? ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const stdout = result.stdout?.toString() ?? ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Surface container logs to make healthcheck failures easier to diagnose in CI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const logs = spawnSync('docker', composeArgs('logs'), { cwd }).stdout?.toString() ?? ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const logs = containerLogs(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| close(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `docker compose up --wait failed (exit ${result.status})\n${stderr}${stdout}\n--- container logs ---\n${logs}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `docker compose up --wait failed (exit ${result.status})\n${output(result)}\n--- container logs ---\n${logs}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pullMs + upMs > SLOW_START_MS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line no-console | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn(`[docker compose] slow start in ${cwd}: pull ${pullMs}ms, up --wait ${upMs}ms`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return close; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as in don't kill the test yet because we get a second try when
docker compose upruns? maybe this could be clarified a bit