reclaim-the-stack / actioncable-enhanced-postgresql-adapter

An enhanced ActionCable adapter for PostgreSQL.
MIT License
114 stars 3 forks source link

zero-length delimited identifier at or near """" #3

Closed holman closed 2 months ago

holman commented 2 months ago

Hi! Just wanted to try switching from my redis setup to this (neat!), but getting this when I try broadcasting on a page:

09:46:07 web.1  | Started GET "/cable" [WebSocket] for ::1 at 2024-08-04 09:46:07 -0700
09:46:07 web.1  | Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
09:46:07 web.1  | Turbo::StreamsChannel is transmitting the subscription confirmation
09:46:07 web.1  | Turbo::StreamsChannel is streaming from hotwire-livereload
09:46:07 web.1  | #<Thread:0x000000012d31fe38 /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:83 run> terminated with exception (report_on_exception is true):
09:46:07 web.1  | /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:98:in `exec': ERROR:  zero-length delimited identifier at or near """" (PG::SyntaxError)
09:46:07 web.1  | LINE 1: LISTEN ""
09:46:07 web.1  |                ^
09:46:07 web.1  |
09:46:07 web.1  |   from /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:98:in `block (3 levels) in listen'
09:46:07 web.1  |   from <internal:kernel>:187:in `loop'
09:46:07 web.1  |   from /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:92:in `block (2 levels) in listen'
09:46:07 web.1  |   from /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:91:in `catch'
09:46:07 web.1  |   from /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:91:in `block in listen'
09:46:07 web.1  |   from /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:47:in `with_subscriptions_connection'
09:46:07 web.1  |   from /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/actioncable-enhanced-postgresql-adapter-1.0.1/lib/action_cable/subscription_adapter/enhanced_postgresql.rb:83:in `with_subscriptions_connection'
09:46:07 web.1  |   from /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:90:in `listen'
09:46:07 web.1  |   from /Users/holman/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/bundler/gems/rails-59064f88d8ab/actioncable/lib/action_cable/subscription_adapter/postgresql.rb:85:in `block in initialize'

Any thoughts?

mwallba commented 2 months ago

@holman this is likely not caused by this adapter specifically and will blow up for the vanilla postgresql actioncable adapter too.

If the name identifying a subscription evaluates to an empty string, it'll be passed through to postgresql's LISTEN and throw the above.

You can reproduce this with turbo streams by putting a <%= turbo_stream_from "" %> into a view somewhere.

Best to check if any of your turbo_stream_from calls eval to an empty string.

holman commented 2 months ago

Oh, duh, yeah that makes total sense. (Think I was just thrown for a loop to see a process termination instead of just a thrown exception!) Thanks for the sanity check- all is good now. :metal: