Skip to content

Commit

Permalink
Make wait noop if scheduled_task is nil
Browse files Browse the repository at this point in the history
This can happen when the Debouncer has finished its work and we clear it
from the current thread. The next call to refresh_debouncer_for creates
a new Debouncer, but it doesn't have a scheduled_task yet.

We only use the wait method in tests, to ensure that the debounces has
finished its work. But if the scheduled_task is nil, we know that the
debouncer has already finished its work.
  • Loading branch information
afcapel committed Nov 16, 2023
1 parent 57671f9 commit 00b2b24
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/turbo/debouncer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def debounce(&block)
end

def wait
scheduled_task.wait(wait_timeout)
scheduled_task&.wait(wait_timeout)
end

private
Expand Down

0 comments on commit 00b2b24

Please sign in to comment.