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

listener.stop fails with undefined method `alive?' for nil:NilClass if called before started #513

Closed
ColinDKelley opened this issue Nov 13, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@ColinDKelley
Copy link
Collaborator

ColinDKelley commented Nov 13, 2020

Current State

If a listener hasn't been started yet, a call to stop will raise an exception:

listener = Listen.to(path) do { ... }
listener.stop
NoMethodError:
       undefined method `alive?' for nil:NilClass
     # /usr/local/bundle/gems/listen-3.3.0/lib/listen/event/loop.rb:70:in `stop'
     # /usr/local/bundle/gems/listen-3.3.0/lib/listen/listener.rb:82:in `block in <class:Listener>'
     # /usr/local/bundle/gems/listen-3.3.0/lib/listen/fsm.rb:121:in `instance_eval'
     # /usr/local/bundle/gems/listen-3.3.0/lib/listen/fsm.rb:121:in `call'
     # /usr/local/bundle/gems/listen-3.3.0/lib/listen/fsm.rb:102:in `transition_with_callbacks!'
     # /usr/local/bundle/gems/listen-3.3.0/lib/listen/fsm.rb:69:in `transition'
     # /usr/local/bundle/gems/listen-3.3.0/lib/listen/listener.rb:101:in `stop'

Desired State

The stop method should always succeed--even when not started.

Steps to Reproduce

Call stop before starting:

listener = Listen.to(path) do { ... }
listener.stop
@ColinDKelley ColinDKelley self-assigned this Nov 13, 2020
ColinDKelley added a commit to Invoca/listen that referenced this issue Nov 13, 2020
@ColinDKelley ColinDKelley changed the title Listen.stop fails with a nil dereference if called while stopped; should be idempotent listener.stop fails with undefined method `alive?' for nil:NilClass if called before started Nov 13, 2020
@ColinDKelley ColinDKelley added this to the v3.3.1 milestone Nov 13, 2020
ColinDKelley added a commit to Invoca/listen that referenced this issue Nov 13, 2020
ColinDKelley added a commit to Invoca/listen that referenced this issue Nov 13, 2020
@ColinDKelley
Copy link
Collaborator Author

Fixed by #514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant