Spin group wait causes ClosedQueueError
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 57
- Avg merge
- 2h 55m
- Merged PRs (30d)
- 2
Description
After updating to 2.2.3 to 2.3.0, waiting in a spingroup seems to have broken and now throws a ClosedQueueError.
Minimal test case:
require 'cli/ui'
CLI::UI::StdoutRouter.enable
CLI::UI::SpinGroup.new do |sg|
# Task 1
sg.add('pending') { |spinner|
result = { 'message' => 'mock api result' }
sleep(0.5)
spinner.update_title(result['message'])
}
# Wait for previous task to finish before starting the next
sg.wait
# Task 2
sg.add('pending 2') { |spinner|
result = { 'message' => 'mock api result 2' }
sleep(0.5)
spinner.update_title(result['message'])
}
end
Full output:
# ruby test.rb
✓ mock api result
/usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/work_queue.rb:86:in `push': queue closed (ClosedQueueError)
from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/work_queue.rb:86:in `enqueue'
from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:135:in `initialize'
from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:315:in `new'
from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:315:in `block in add'
from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:314:in `synchronize'
from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:314:in `add'
from test.rb:17:in `block in <main>'
from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:93:in `initialize'
from test.rb:5:in `new'
from test.rb:5:in `<main>'
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the regression with test.rb using the minimal SpinGroup example, then inspect lib/cli/ui/work_queue.rb:86 and lib/cli/ui/spinner/spin_group.rb:135, 314-315. Trace why sg.wait closes the queue before the second sg.add enqueues work; done when the example completes both tasks without ClosedQueueError and a regression test covers it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100