Skip to content

Move dap setup to setup job step#4403

Open
rentziass wants to merge 2 commits intomainfrom
dapsetup
Open

Move dap setup to setup job step#4403
rentziass wants to merge 2 commits intomainfrom
dapsetup

Conversation

@rentziass
Copy link
Copy Markdown
Member

This adds the DAP server setup to the Setup job step, to both help with messaging for users and keep the step as in progress to communicate we're waiting on a debugger to connect.

We also add a final pause during the Complete job step to allow one final inspection after all steps have completed.
CleanShot 2026-05-05 at 16 21 37@2x
CleanShot 2026-05-05 at 16 22 27@2x

https://github.com/github/c2c-actions/issues/9828

@rentziass rentziass marked this pull request as ready for review May 5, 2026 16:49
@rentziass rentziass requested a review from a team as a code owner May 5, 2026 16:49
Copilot AI review requested due to automatic review settings May 5, 2026 16:49
{
try
{
var cancellationToken = _jobContext?.CancellationToken ?? CancellationToken.None;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this relies on IsActive always implying _jobContext != null which is true right now but feels fragile. if that invariant breaks later this silently hangs the runner. can we just bail early?

Suggested change
var cancellationToken = _jobContext?.CancellationToken ?? CancellationToken.None;
if (_jobContext == null)
{
Trace.Warning("No job context available, skipping completion pause.");
break;
}
var cancellationToken = _jobContext.CancellationToken;

// Pause for debugger inspection, then tear down the DAP session.
// OnJobCompletedAsync pauses first, then sends terminated/exited
// events and stops the transport.
if (_dapDebugger != null)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: init-failure path nulls _dapDebugger after cleanup but this doesn't. doesn't matter since JobExtension is per-job and StopAsync() handles the real teardown, just looks inconsistent

catch (Exception ex)
{
Trace.Error($"Failed to start DAP debugger: {ex.Message}");
AddDebuggerConnectionTelemetry(jobContext, $"Failed: {ex.Message}");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ex.Message going into JobTelemetry, probably fine since the host token goes in auth headers not URLs, but I don't see HostToken registered with SecretMasker either. safer to just log the type:

Suggested change
AddDebuggerConnectionTelemetry(jobContext, $"Failed: {ex.Message}");
AddDebuggerConnectionTelemetry(jobContext, $"Failed: {ex.GetType().Name}");

full message is already in Trace.Error

Copy link
Copy Markdown
Contributor

@salmanmkc salmanmkc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple tests that'd be nice to have:

  • cancellation during WaitForCommandAsync (not just pre-cancelled)
  • exception in OnJobCompletedAsync during FinalizeJob

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants