Skip to content

[Bug]: Property observation leaks event handlers when initial subscription throws #1176

Description

@dwcullop

Please note we can't commit to any timeline.

Describe the bug 🐞

Shallow and deep property-observation subscription constructors install event handlers and then perform initial reads/delivery. If a getter failure reaches the default throwing error handler, or an initial OnNext callback throws, construction never returns the disposable to Rx. The installed handlers retain the failed subscription.

Step to reproduce

Use an INotifyPropertyChanged model with counted event add/remove accessors. Subscribe with an initial observer that throws, or with an initial getter that throws and the default error handler. Inspect handler counts after Subscribe throws. Repeat with a multi-level property chain and partially attached chain.

Regression tests/checks:

Shallow_InitialObserverThrows_DetachesHandler; DeepChain_InitialObserverThrows_DetachesEveryHandler; Shallow_InitialGetterThrows_DefaultErrorHandler_DetachesHandler; DeepChain_InitialGetterThrows_DefaultErrorHandler_DetachesEveryHandler

Reproduction repository

https://github.com/reactivemarbles/DynamicData/tree/85ee49cfd54d8782c36ed137886d318e942345c4

Regression tests and fixes:
https://github.com/reactivemarbles/DynamicData/tree/u/dacullop/main/pr-1165-review

Expected behavior

Every installed handler must be detached when initialization fails, while preserving the original exception and valid initial/property-change notifications.

Screenshots 🖼️

N/A.

IDE

N/A; command-line reproduction.

Operating system

Windows.

Version

.NET SDK 10.0.401; net9.0 test target.

Device

N/A.

DynamicData Version

Main 10.0-preview at 85ee49c. The related 9.5 candidate is PR #1165 at 3d76872.

Additional information ℹ️

Repository tests retain one shallow handler or deep handler counts of [1,1,1] / [1,1] instead of zero. Controls with an explicit nonthrowing error recorder pass.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions