google-cloud-ruby: Firestore listen eventually fails

Environment details

  • OS: Heroku
  • Ruby version: 2.7.0p0
  • Gem name and version: google-cloud-firestore (2.4.1)

Steps to reproduce

Running this on Heroku as a separate dyno via Procfile (firestore: bundle exec ruby lib/listen_to_firestore.rb):

# Load Rails environment
require File.expand_path('../../config/environment', __FILE__)

firestore = Google::Cloud::Firestore.new(
  project_id: '...',
  credentials: { ... },
)

firestore.collection_group('thread').order('createdAt', 'desc').limit(25).listen do |snapshot|
  snapshot.changes.each do |change|
    # ActiveRecord stuff
  end
end

puts "Listening..."
while true
  sleep 0.05
end

After a while, the thread crashes with No status received.

Full backtrace

2021-03-14T16:54:20.962157+00:00 app[firestore.1]: #<Thread:0x000055df0b291450 /app/vendor/bundle/ruby/2.7.0/gems/google-cloud-firestore-2.4.1/lib/google/cloud/firestore/watch/listener.rb:129 run> terminated with exception (report_on_exception is true):
2021-03-14T16:54:20.965255+00:00 app[firestore.1]: /app/vendor/bundle/ruby/2.7.0/gems/grpc-1.36.0-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:29:in `check_status': 2:No status received. debug_error_string:{"created":"@1615740860.961643731","description":"No status received","file":"src/core/lib/surface/call.cc","file_line":1091,"grpc_status":2} (GRPC::Unknown)
2021-03-14T16:54:20.965302+00:00 app[firestore.1]: from /app/vendor/bundle/ruby/2.7.0/gems/grpc-1.36.0-x86_64-linux/src/ruby/lib/grpc/generic/bidi_call.rb:209:in `block in read_loop'
2021-03-14T16:54:20.965330+00:00 app[firestore.1]: from /app/vendor/bundle/ruby/2.7.0/gems/grpc-1.36.0-x86_64-linux/src/ruby/lib/grpc/generic/bidi_call.rb:195:in `loop'
2021-03-14T16:54:20.965357+00:00 app[firestore.1]: from /app/vendor/bundle/ruby/2.7.0/gems/grpc-1.36.0-x86_64-linux/src/ruby/lib/grpc/generic/bidi_call.rb:195:in `read_loop'
2021-03-14T16:54:20.965382+00:00 app[firestore.1]: from lib/listen_to_firestore.rb:in `each'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

It works! Thank you so much 😃

Yes, you can retry on UNKNOWN.

When you turn off the restart process, can you also try to enable grpc debug logging (assuming doing so is not a security problem)?

https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md