Skip to content

Don't wrap cancellation exceptions from asynchronous writes - #2388

Open
justadityaraj wants to merge 1 commit into
JoshClose:masterfrom
justadityaraj:fix/2277-preserve-cancellation
Open

Don't wrap cancellation exceptions from asynchronous writes#2388
justadityaraj wants to merge 1 commit into
JoshClose:masterfrom
justadityaraj:fix/2277-preserve-cancellation

Conversation

@justadityaraj

Copy link
Copy Markdown

Problem

WriteRecordsAsync catches OperationCanceledException and wraps it in WriterException. That makes normal cancellation indistinguishable from an unexpected CSV write failure to callers.

Fixes #2277

Fix

Exclude OperationCanceledException from the existing exception filters in all three WriteRecordsAsync overloads. Tighten the existing cancellation test so it requires the public operation to throw OperationCanceledException directly.

User impact

Callers can use the standard cancellation exception path for asynchronous record writes, including TaskCanceledException through its OperationCanceledException base type.

Verification

  • CsvHelper.Tests.Async.WritingTests on net9.0 Release: 3 passed
  • Full CsvHelper.Tests on net9.0 Release: 1,061 passed; the two remaining Windows newline failures reproduce unchanged on clean master
  • Complete diff whitespace check passed with the repository's CRLF convention

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.

Please don't wrap OperationCanceledException in CsvHelper.WriteRecordsAsync

1 participant