Spin group wait causes ClosedQueueError

Open
#575 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
ruby
Domain
cli

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.

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>'
Dominant language
Ruby
Stars
1.1k
Forks
57
Avg merge
2h 55m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Shopify/cli-ui

All issues in Shopify/cli-ui

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.