dap: fix the race condition in the dap unit tests#3710
Merged
tonistiigi merged 1 commit intodocker:masterfrom Mar 11, 2026
Merged
dap: fix the race condition in the dap unit tests#3710tonistiigi merged 1 commit intodocker:masterfrom
tonistiigi merged 1 commit intodocker:masterfrom
Conversation
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>
61e643c to
ca9df87
Compare
tonistiigi
approved these changes
Mar 11, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.Cleanupwhich executes inits 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
Stopwhen they are donewith 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.