File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type * as http from 'http';
22import type * as ws from 'ws' ;
33import { makeServer , ServerOptions } from '../server' ;
44import { Disposable } from '../types' ;
5+ import { GRAPHQL_TRANSPORT_WS_PROTOCOL } from '../protocol' ;
56
67// for nicer documentation
78type WebSocket = typeof ws . prototype ;
@@ -108,6 +109,14 @@ export function useServer(
108109 socket . once ( 'close' , ( code , reason ) => {
109110 if ( pongWait ) clearTimeout ( pongWait ) ;
110111 if ( pingInterval ) clearInterval ( pingInterval ) ;
112+ if ( ! isProd && code === 1002 ) {
113+ console . warn (
114+ `WebSocket protocol error occured. It was most likely caused due to an ` +
115+ `unsupported subprotocol "${ socket . protocol } " requested by the client. ` +
116+ `graphql-ws implements exclusively the "${ GRAPHQL_TRANSPORT_WS_PROTOCOL } " subprotocol, ` +
117+ 'please make sure that the client implements it too.' ,
118+ ) ;
119+ }
111120 closed ( code , reason ) ;
112121 } ) ;
113122 } ) ;
You can’t perform that action at this time.
0 commit comments