Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve errors when an item no longer exists #354

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Nov 17, 2024

  1. fix race condition when using semantic methods

    Enumerable and predicate methods will now behave better when they refer
    to stale proxies - filtering methods will just remove them. I run into
    this occasionally when I have multiple rules firing, and some of them
    are adding or removing items - and calling items.locations would raise
    a NoMethodError for #location? due to a race condition. This should no
    longer happen - it will just ignore the now-stale items.
    
    Signed-off-by: Cody Cutrer <[email protected]>
    ccutrer committed Nov 17, 2024
    Configuration menu
    Copy the full SHA
    439921c View commit details
    Browse the repository at this point in the history
  2. Improve errors when an item no longer exists

    If a user keeps a ref to an item, and that item disappears,
    calling a method on that item will now raise a helpful
    StaleProxyError, instead of a NoMethodError on nil
    
    The proxy code was significantly refactored, and Thing
    proxies will also inherit the same stale proxy handling.
    I also removed the $things registry lookup on every access
    of a thing, using the same event subscriber mechanism as Item.
    
    I also moved several methods from GenericItem to Item, so that
    Proxy can detect that those methods should exist even for
    dummy/stale items.
    
    Signed-off-by: Cody Cutrer <[email protected]>
    ccutrer committed Nov 17, 2024
    Configuration menu
    Copy the full SHA
    9acceb6 View commit details
    Browse the repository at this point in the history