Skip to content

fix: preserve async application exception origin (#108) - #113

Draft
AGiorgetti wants to merge 2 commits into
developfrom
fix/108-async-exception-origin
Draft

AGiorgetti wants to merge 2 commits into
developfrom
fix/108-async-exception-origin

Conversation

@AGiorgetti

Copy link
Copy Markdown
Member

Summary

  • Preserve application serializer and OnNextAsync Mongo exceptions in async observer reads by default; continue translating adapter Mongo failures.
  • Add MongoPersistenceOptions.WrapAsyncApplicationExceptions = true to restore stable 12.1.0 wrapping.
  • Add Breaking Changes and migration notes, including the custom protected-guard override caveat.

Closes #108.

Validation

  • Test-first: 40 expected failures before the implementation.
  • Cloud: 520 focused [P3] Review async exception translation for serializer and observer failures #108 tests passed on .NET 10 with MongoDB Driver 3.13.0, zero skipped, including suspended callback faults, stack trace, early stop and opt-out coverage.
  • Earlier cancellation and regression run: 453 passed, zero skipped.
  • Whitespace/diff check passed after transfer to an isolated local checkout.
  • Driver 3.0.0 verification was blocked during restore by MSBuild named-mutex initialization. Other target frameworks and full integration suite remain unverified.

Compatibility / review notes

  • Public/protected signatures and one guard invocation are preserved.
  • Custom TryMongoAsync overrides that inspect callback exceptions can see an internal marker by default. Non-base overrides should opt out to preserve the previous callback contract.
  • Per-item async helper overhead has not been benchmarked; no per-item delegate is introduced.

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

AGiorgetti and others added 2 commits November 12, 2026 12:29
Default async observer reads to preserve application Mongo exceptions. Add a legacy opt-out and document the breaking change.

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

Co-authored-by: Codex (OpenAI) <codex@openai.com>
Return completed observer tasks directly and share the async exception-marking slow path. Preserve legacy opt-out task forwarding.

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

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

Copy link
Copy Markdown
Member Author

Refactored the per-item observer helpers at the owner's request:

  • Successfully completed observer tasks are returned directly, without an additional async wrapper.
  • Legacy opt-out forwards the original task, including pending/faulted/canceled tasks.
  • A shared async slow path still marks deferred application Mongo exceptions. Synchronous conversion/callback exceptions remain guarded; outer virtual guard and API signatures are unchanged.
  • Added task-identity and deterministic delayed true/false tests. Existing exception identity, delayed failures, cancellation and notification tests remain passing.

Verification: 14 new identity tests failed before the change; final focused regression suite has 587 tests passing with zero skipped in all eight net472/net8/net9/net10 × Driver 3.0.0/3.13.0 lanes. Full net10/Driver 3.13.0 suite against isolated MongoDB 8: 1,680 passed, zero skipped. Independent review found no correctness blocker. No benchmark was run, so no quantified throughput/allocation improvement is claimed. Existing protected-override caveat is unchanged.

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

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.

[P3] Review async exception translation for serializer and observer failures

1 participant