wundergraph/cosmo

For subscriptions, router should auto re-connect after subgraph server restarts

Opened this issue · 3 comments

Component(s)

router

Component version

v0.98.2

wgc version

v0.58.5

controlplane version

n/a

router version

v0.98.2

What happened?

Description

For subscriptions, router doesn't auto re-connect when subgraph server restarts

Steps to Reproduce

  1. open a websocket connection to router, make a subscription call, router will open a new websocket connection to subscription subgraph server
  2. restart subscription subgraph server

Expected Result

  1. router auto re-connects to subscription subgraph server, open a new websocket connection and remake that subscription call

Actual Result

  1. the websocket connection between router and subscription subgraph server is gone

Environment information

Environment

OS: Ubuntu 20.04
Package Manager: pnpm
Compiler: go 1.22

Router configuration

dev_mode: true
listen_addr: 0.0.0.0:3009
router_config_path: config_dev.json
authentication:
  providers:
    - name: Auth Provider
      jwks: # JWKS provider configuration
        url: http://auth-gateway:8085/.well-known/jwks.json
        header_names: [Authorization]
        header_value_prefixes: [Bearer]
        refresh_interval: 2h
authorization:
  require_authentication: true
websocket:
  absinthe_protocol:
    enabled: false
file_upload:
  enabled: true
  max_file_size: 50MB
  max_files: 2
graph:
  # Result of `wgc router token create`. Can be omitted for local testing.
  token: ""

Router execution config

I'm testing locally.  I'm using custom modules, so I'm building router image locally.  Custom module code just maps JWT claims information to headers of subgraph requests

Log output

No response

Additional context

No response

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible.
The roadmap is driven by our customers and we have to prioritize issues that are important to them.
You can influence the priority by becoming a customer. Please contact us here.

Hi @agufagit thank you for the report. We will take a look and come back.

@StarpTech I am running in to this issue as well.

The router solution we are currently using is using graphql-tools. This will, transparently to the client, reconnect webosckets if a subgraph goes down.

Cosmo on graphql-transport-ws seems to currently be sending a complete for a subscription if its corresponding subgraph goes down. The client is unable to tell if this is because there is no more data or if this is because the subgraph went down and it should re-subscribe.

If the router reconnects to the subgraph and resubscribes for the client this assists with that, or if it sends an error then the client can at least determine that it should re-subscribe and rebuilt state if necessary.