ostinelli / apnotic

A Ruby APNs HTTP/2 gem able to provide instant feedback.
MIT License
477 stars 94 forks source link

Getting "LocalJumpError no block given (yield)" error when using connection pool with 1.4.0 version #71

Closed IevgenRagulin closed 5 years ago

IevgenRagulin commented 6 years ago

I've just updated to 1.4.0 version (I did that accidentally, I wanted to use 1.3.1), and I started getting this error: LocalJumpError: no block given (yield)

for this code:

apnotic_pool.with do |connection|
      logger.info "Sending push notification to APNS"
end
ostinelli commented 6 years ago

After https://github.com/ostinelli/apnotic/commit/211f8b01a3d0e9bf783385b5c8a9869af9ceef1a you need to specify a block:

 APNOTIC_POOL = Apnotic::ConnectionPool.new({
    cert_path: Rails.root.join("config", "certs", "apns_certificate.pem"),
    cert_pass: "mypass"
  }, size: 5) do |connection|
    connection.on(:error) { |exception| puts "Exception has been raised: #{exception}" }
  end

This is what LocalJumpError: no block given (yield) means.

ostinelli commented 6 years ago

cc @krasnoukhov

krasnoukhov commented 6 years ago

Yeah, a block is required now, this is why exception is raised

ostinelli commented 6 years ago

Right, except this is not backwards compatible. A little borderline re: SemVer, but will maybe just clarify the error a little better.

krasnoukhov commented 6 years ago

Ok, makes sense to clarify it. I think it was meant to not be backwards compatible so users will have to change in order to make this code safe

ostinelli commented 6 years ago

Apnotic upgraded to 1.4.1 with hopefully a clear action point: https://github.com/ostinelli/apnotic/commit/76418499e1052f719d21a419ef0e962d79761f97

@IevgenRagulin thank you for reporting this.