Skip to content

dap: fix the race condition in the dap unit tests#3710

Merged
tonistiigi merged 1 commit intodocker:masterfrom
jsternberg:dap-tests-race-condition
Mar 11, 2026
Merged

dap: fix the race condition in the dap unit tests#3710
tonistiigi merged 1 commit intodocker:masterfrom
jsternberg:dap-tests-race-condition

Conversation

@jsternberg
Copy link
Copy Markdown
Collaborator

The context used for serving the dap server was being canceled too early
because it used defer which would initiate at the end of the function
while every other cleanup function used t.Cleanup which executes in
its own goroutine.

One possible solution was to move the cancel to the cleanup, but the
context being passed to serve and start doesn't make sense because if it
ever does get canceled, it'll likely cause a similar race condition with
Stop.

This removes the context from the methods that were causing this issue
in favor of just relying on the caller calling Stop when they are done
with the adapter and server.

This seems to have only affected tests and I don't believe it affected
the actual dap command.

Fixes #3695.

Possibly fixes #3598.

The context used for serving the dap server was being canceled too early
because it used defer which would initiate at the end of the function
while every other cleanup function used `t.Cleanup` which executes in
its own goroutine.

One possible solution was to move the cancel to the cleanup, but the
context being passed to serve and start doesn't make sense because if it
ever does get canceled, it'll likely cause a similar race condition with
`Stop`.

This removes the context from the methods that were causing this issue
in favor of just relying on the caller calling `Stop` when they are done
with the adapter and server.

This seems to have only affected tests and I don't believe it affected
the actual dap command.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
@jsternberg jsternberg force-pushed the dap-tests-race-condition branch from 61e643c to ca9df87 Compare March 10, 2026 17:03
@tonistiigi tonistiigi merged commit 9e31c0f into docker:master Mar 11, 2026
159 checks passed
@jsternberg jsternberg deleted the dap-tests-race-condition branch March 11, 2026 05:15
@crazy-max crazy-max added this to the v0.33.0 milestone Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test - github.com/docker/buildx/dap Flaky test: TestSetBreakpoints

3 participants