diff --git a/lib/bunny/channel.rb b/lib/bunny/channel.rb index 126f17c45..7d5118098 100644 --- a/lib/bunny/channel.rb +++ b/lib/bunny/channel.rb @@ -1783,6 +1783,8 @@ def wait_on_basic_get_continuations # @private def wait_on_confirms_continuations + raise_if_no_longer_open! + if @connection.threaded t = Thread.current @threads_waiting_on_confirms_continuations << t diff --git a/spec/higher_level_api/integration/publisher_confirms_spec.rb b/spec/higher_level_api/integration/publisher_confirms_spec.rb index 3eb422653..76bca7f91 100644 --- a/spec/higher_level_api/integration/publisher_confirms_spec.rb +++ b/spec/higher_level_api/integration/publisher_confirms_spec.rb @@ -60,6 +60,18 @@ }.not_to raise_error end + + it "raises an error when called on a closed channel" do + ch = connection.create_channel + + ch.confirm_select + + ch.close + + expect { + ch.wait_for_confirms + }.to raise_error(Bunny::ChannelAlreadyClosed) + end end context "when some of the messages get nacked" do