Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get ActionCable subscriptions to work #4792

Closed
fazo96 opened this issue Jan 19, 2024 · 1 comment · Fixed by #4793
Closed

Can't get ActionCable subscriptions to work #4792

fazo96 opened this issue Jan 19, 2024 · 1 comment · Fixed by #4793

Comments

@fazo96
Copy link

fazo96 commented Jan 19, 2024

Describe the bug

There's two issues:

  1. the browser fails to connect to the websocket semi-randomly. This happens almost always on firefox and sometimes on chrome. The WS connection shows up in the Network tab devtools but no messages are exchanged. This might not be a Graphql-ruby bug but I thought I'd mention it. I am still trying to figure this one out
  2. ActionCable internally logs a cryptic error

Issue 2 I think is most likely a bug in graphql-ruby

The error message is: [GraphqlChannel] Unable to process GraphqlChannel#send({"variables"=>{"userId"=>nil}, "operationName"=>"useWorkspaceLoader_Subscription", - I cut off the rest which isn't important

I traced it here in the rails source code: https://github.com/rails/rails/blob/21eceb7db26b724d1f7a824d4cc04ddeba44244b/actioncable/lib/action_cable/channel/base.rb#L176

I think the issue is that the graphql client will try to perform a "send" operation but the channel on the ruby code only has a handler for the "execute" operation, see here:

channel.perform('send', channelParams)
channel.perform("execute", channelParams)

Versions

graphql version: 2.2.4
rails (or other framework): 7.1

GraphQL schema

I don't think it's relevant

GraphQL query

I don't think it's relevant

Steps to reproduce

Setting up a project with Relay on the frontend and ActionCable on the backend and trying to run subscriptions

Expected behavior

Subscriptions work fine

Actual behavior

I can't get them to actually work even though there is no exception with stack trace anywhere

Additional context

The project is a Next.js app using the "pages" folder for setting up routes

@rmosolgo
Copy link
Owner

Hey, thanks for reporting this. It certainly sounds possible that the perform("send", ...) call doesn't belong. Somehow it snuck in there three years ago: cf0a3fe#diff-9957e220f3cd45075c8bd11a71aa74970869a76e46eaff6007685295c806c6fdR45

I've worked up a patch to remove that call here: #4793

If you add a dummy def send(_data); end in your ActionCable channel, does that make the error go away? (I think that would make the perform("send", ...) call "work"....)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants