Skip to content

fix: Invoke-DataverseSql doesn't respond to CTRL+C#1410

Open
Copilot wants to merge 6 commits intomainfrom
copilot/fix-ctrl-c-responsiveness
Open

fix: Invoke-DataverseSql doesn't respond to CTRL+C#1410
Copilot wants to merge 6 commits intomainfrom
copilot/fix-ctrl-c-responsiveness

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

Description

Invoke-DataverseSql ignored CTRL+C during query execution, only responding after results began streaming. The cmdlet's StopProcessing() method created a cancellation token but never passed it to the underlying SQL4CDS engine.

Changes Made

  • Pass _userCancellationCts.Token to ExecuteReaderAsync() to enable query cancellation
  • Add IsCanceled check before accessing task result to handle graceful cancellation
  • Remove Task.Run wrapper (unnecessary - ExecuteReaderAsync already returns a Task)
  • Remove outdated comment claiming SQL4CDS lacks cancellation support

Key change:

// Before
Task<DbDataReader> task = Task.Run(() => _command.ExecuteReaderAsync());

// After  
Task<DbDataReader> task = _command.ExecuteReaderAsync(_userCancellationCts.Token);

Testing

  • Build succeeds with no errors
  • Manual testing with long-running queries to verify CTRL+C responsiveness

Checklist

  • Code follows the project's coding conventions
  • Documentation updated (if needed)
  • Tests added/updated (if needed)
  • PR title uses conventional commit format (REQUIRED)
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] Invoke-dataversesql doesn't respond to CTRL+C (until results start streaming?)</issue_title>
<issue_description>### Description

Steps to Reproduce

Expected Behavior

Actual Behavior

PowerShell version

Module Version

No response

Additional Context

No response

Checklist

  • I have tried the latest version of the module
  • I have searched for similar issues and couldn't find any
  • I have included all the information needed to reproduce the issue</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 6, 2026 18:57
Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
- Pass cancellation token to ExecuteReaderAsync to enable query cancellation
- Add checks for cancelled/faulted tasks before accessing results
- Remove outdated comment about SQL4CDS not supporting cancellation

Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
- Remove unnecessary Task.Run wrapper around ExecuteReaderAsync
- Simplify exception handling to let task.Result propagate exceptions naturally

Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
- task.Result naturally propagates exceptions, making the separate IsFaulted check unnecessary
- Simplifies code and improves clarity

Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix invoke-dataversesql not responding to CTRL+C fix: Invoke-DataverseSql doesn't respond to CTRL+C Feb 6, 2026
Copilot AI requested a review from rnwood February 6, 2026 19:08
@rnwood rnwood marked this pull request as ready for review February 8, 2026 11:38
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.

[BUG] Invoke-dataversesql doesn't respond to CTRL+C (until results start streaming?)

2 participants