Skip to content

Dispose wrapped commands asynchronously - #2264

Closed
alaricd wants to merge 2 commits into
DapperLib:mainfrom
pengdows:fix/issue-2185
Closed

alaricd wants to merge 2 commits into
DapperLib:mainfrom
pengdows:fix/issue-2185

Conversation

@alaricd

@alaricd alaricd commented Oct 24, 2026

Copy link
Copy Markdown

Fixes #2185.

DbWrappedReader.DisposeAsync() previously disposed only the underlying reader, leaving the associated command undisposed when callers used await using with ExecuteReaderAsync. This adds async cleanup parity with synchronous disposal and a fakeDb regression test that verifies the command is disposed.

alaricd and others added 2 commits October 24, 2026 08:09
Mirror GridReader.DisposeAsync: await DbCommand.DisposeAsync, fall back to Dispose for other
IDbCommand implementations, and dispose the command even when reader disposal throws.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@mgravell

Copy link
Copy Markdown
Member

Good catch — the async dispose path really did leak the command, and your production change is adopted essentially as-is in #2272. The tests there are built on the existing WrappedReaderTests fakes rather than adding a new test dependency; see #2199 for the general note on that. Thanks!

@mgravell mgravell closed this Nov 20, 2026
mgravell added a commit that referenced this pull request Nov 20, 2026
…tatic properties, and type-map races (#2272)

Five small fixes, each identified by community PRs (credit: alaricd), re-tested
on the repo's existing test infrastructure:

- DbWrappedReader.DisposeAsync now disposes the wrapped command, mirroring the
  sync Dispose path; 'await using' on an ExecuteReaderAsync result previously
  leaked the command (#2185, community PR #2264)
- QueryMultiple / QueryMultipleAsync now pass custom IParameterCallbacks
  implementations to the GridReader, not just DynamicParameters, so OnCompleted
  fires for them (#2179, community PR #2257, extended to the async call site)
- AddTypeHandler purges compiled deserializer caches: a handler registered
  after a deserializer was compiled for a containing type is now honored
  (community PR #2247)
- public static properties on parameter objects are ignored: the emitted IL
  loads the instance before each getter call, which is an invalid program for
  a static getter (community PR #2254)
- AddTypeMap / RemoveTypeMap clone-and-swap now happens under a lock, so
  concurrent registrations cannot lose each other's updates (community PR #2251)

Fixes #2179, fixes #2185
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.

Command not disposed with async using and ExecuteReaderAsync

2 participants