You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
client: Deprecate isFatalConnectionProblem option in favour of shouldRetry (d8dcf21)
Client usage with retry on any connection problem
import{createClient}from'graphql-ws';import{waitForHealthy}from'./my-servers';constclient=createClient({url: 'ws://any.retry:4000/graphql',// by default the client will immediately fail on any non-fatal// `CloseEvent` problem thrown during the connection phase//// see `retryAttempts` documentation about which `CloseEvent`s are// considered fatal regardlessshouldRetry: ()=>true,// or pre v5.8.0:// isFatalConnectionProblem: () => false,});
client: Terminate the WebSocket abruptly and immediately (53ad515), closes #290
Client usage with abrupt termination on pong timeout
import{createClient}from'graphql-ws';lettimedOut;constclient=createClient({url: 'ws://terminate.me:4000/on-pong-timeout',keepAlive: 10_000,// ping server every 10 secondson: {ping: (received)=>{if(!received/* sent */){timedOut=setTimeout(()=>{// a close event `4499: Terminated` is issued to the current WebSocket and an// artificial `{ code: 4499, reason: 'Terminated', wasClean: false }` close-event-like// object is immediately emitted without waiting for the one coming from `WebSocket.onclose`//// calling terminate is not considered fatal and a connection retry will occur as expected//// see: https://github.com/enisdenjo/graphql-ws/discussions/290client.terminate();},5_000);}},pong: (received)=>{if(received){clearTimeout(timedOut);}},},});