Skip to content

Align async Mongo exception boundaries with synchronous reads (#108) - #116

Merged
AGiorgetti merged 3 commits into
developfrom
fix/108-driver-only-boundaries
Nov 17, 2026
Merged

AGiorgetti merged 3 commits into
developfrom
fix/108-driver-only-boundaries

Conversation

@AGiorgetti

Copy link
Copy Markdown
Member

Summary

Alternative implementation for #108, based directly on develop. Keeps #113 untouched for comparison; merge only one implementation.

  • Pair EnumerateMongoAsync with synchronous EnumerateMongo: translate cursor acquisition and batch advancement only.
  • Preserve original serializer, observer and cursor-disposal exceptions without per-item markers or wrapper tasks.
  • Separate observer notifications from translation, preserving cancellation, ordering, backpressure, early-stop and terminal-callback behavior.
  • Keep WrapAsyncApplicationExceptions=true as a true legacy whole-read path.

Breaking changes

Default application/cleanup Mongo exceptions reach OnErrorAsync unchanged. Driver failures retain storage wrappers and original InnerException. Protected non-result TryMongoAsync overrides now run per driver operation without an observer, not once around the read; callback/cleanup interception changes. Legacy opt-out preserves whole-read wrapping and scope. Public observer signatures unchanged. Cursor cleanup matches sync plain using semantics. See changelog migration notes.

Verification

  • 705 focused exception/cancellation/notification tests passed with zero skips across net472/net8/net9/net10 and MongoDB Driver 3.0.0/3.13.0 (eight lanes).
  • Full net10.0 / Driver3.13.0 suite against isolated MongoDB8: 1,798 passed, zero failed/skipped.
  • Updated existing Issue86 wrapper-count assertion for intentional per-driver scope; preserved notification assertions and explicit legacy coverage.
  • Independent implementation review: no blocking findings.
  • Performance is unbenchmarked; no measured speedup claimed.

Co-authored-by: Alessandro Giorgetti alessandro.giorgetti@live.com
Co-authored-by: Codex (OpenAI) codex@openai.com

Co-authored-by: Alessandro Giorgetti <alessandro.giorgetti@live.com>

Co-authored-by: Codex (OpenAI) <codex@openai.com>
@AGiorgetti AGiorgetti changed the title Align async Mongo exception boundaries with synchronous reads Align async Mongo exception boundaries with synchronous reads (#108) Nov 17, 2026
Co-authored-by: Alessandro Giorgetti <alessandro.giorgetti@live.com>

Co-authored-by: Codex (OpenAI) <codex@openai.com>
@AGiorgetti

Copy link
Copy Markdown
Member Author

Forwarding-lambda cleanup pushed in 606a417: seven read callbacks now return EnumerateMongoAsync directly. Protected guard signatures, observer semantics and legacy behavior are unchanged.

Regression coverage adds synchronous cursor acquisition failures across all seven routes in default and legacy modes. 789 focused exception/cancellation/notification tests pass in all eight lanes (net472/net8/net9/net10 with MongoDB.Driver 3.0.0 and 3.13.0). Full net10/Driver 3.13/MongoDB 8 suite: 1,882 passed, zero failed or skipped. No performance benchmark or measured speedup claimed.

Co-authored-by: Alessandro Giorgetti alessandro.giorgetti@live.com
Co-authored-by: Codex (OpenAI) codex@openai.com

@AGiorgetti
AGiorgetti marked this pull request as ready for review November 17, 2026 14:14
@AGiorgetti
AGiorgetti requested a balanced review from Copilot November 17, 2026 14:15
@AGiorgetti AGiorgetti self-assigned this Nov 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the async observer-read exception-boundary changes.

No open issues 🎉

What changed in this PR

Addresses #108 by aligning async observer-read exception boundaries with synchronous reads in the MongoDB persistence adapter.

Changes:

  • Limits default storage-error translation to cursor acquisition and advancement, preserving application and cleanup exceptions.
  • Adds a legacy whole-read wrapping option and documents migration implications for protected guard overrides.
  • Adds exception-origin and notification tests, and updates cancellation-test expectations for per-driver guard calls.
File Description
src/​NEventStore.Persistence.MongoDB/​MongoPersistenceOptions.cs Adds the legacy exception-wrapping option.
src/​NEventStore.Persistence.MongoDB/​MongoPersistenceEngine.Async.cs Separates driver-error translation from application callbacks and observer notifications.
src/​NEventStore.Persistence.MongoDB.Tests/​AcceptanceTests/​Issues/​Issue86CancellationTests.Async.cs Updates expected guard invocation counts.
src/​NEventStore.Persistence.MongoDB.Tests/​AcceptanceTests/​Issues/​Issue108AsyncExceptionOrigin.cs Tests exception identity, legacy wrapping, cancellation, notifications, and disposal.
Changelog.md Documents breaking behavior and migration options.

Review effort: Balanced

…ult value for cancellationToken in async methods
@AGiorgetti
AGiorgetti merged commit 60cc74e into develop Nov 17, 2026
9 checks passed
@AGiorgetti
AGiorgetti deleted the fix/108-driver-only-boundaries branch November 18, 2026 10:27
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.

2 participants