Skip to content

Add regression tests for disconnected event source cache targets - #2645

Open
Sergio Pedri (Sergio0694) wants to merge 1 commit into
staging/3.0from
user/sergiopedri/port-event-source-cache-expired
Open

Sergio Pedri (Sergio0694) wants to merge 1 commit into
staging/3.0from
user/sergiopedri/port-event-source-cache-expired

Conversation

@Sergio0694

Copy link
Copy Markdown
Member

Ports #2644 (fixes #2643) to staging/3.0.

Changes

In 3.0, EventSourceCache.ResolveTargetUnsafe already treats any failed IWeakReference::Resolve HRESULT (including RPC_E_DISCONNECTED and HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE)) as an expired target, so lookup returns no state and replacement installs a fresh target and clears stale states. The 2.x bug (exceptions propagating) therefore does not exist here, and no behavior change is made.

Unlike the 2.x PR, unrelated failures (E_FAIL, E_ACCESSDENIED) are intentionally not propagated: narrowing would risk permanently blocking event registration for a reused native pointer, would miss other server-gone HRESULTs, and GetState runs on the unsubscription path.

  • Document this behavior on ResolveTargetUnsafe.
  • Add MSTest regression tests to EventSourceCacheTests using [UnsafeAccessor] and a fake native IWeakReferenceSource/IWeakReference whose Resolve can be made to fail: failed resolve is treated as expired in GetState, Create replaces the target and drops old states, and live targets preserve states.

Validation

Release x64 Native AOT publish of UnitTest (warnings as errors on); all 11 EventSourceCacheTests tests pass.

Port of #2644 to staging/3.0. The 3.0 EventSourceCache already treats any failed IWeakReference.Resolve (including RPC_E_DISCONNECTED and RPC_S_SERVER_UNAVAILABLE) as an expired target, so no behavior change is needed. Document that behavior and add tests using a fake native IWeakReferenceSource.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

1 participant