From a80e7534cc0570fa111e15f196ba53fdb5ced667 Mon Sep 17 00:00:00 2001 From: Denis Badurina Date: Tue, 18 May 2021 10:36:41 +0200 Subject: [PATCH] fix(server): Init context first on connection open Closes #181 --- src/server.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server.ts b/src/server.ts index f7992797..3d93d1bc 100644 --- a/src/server.ts +++ b/src/server.ts @@ -518,6 +518,13 @@ export function makeServer(options: ServerOptions): Server { return { opened(socket, extra) { + const ctx: Context = { + connectionInitReceived: false, + acknowledged: false, + subscriptions: {}, + extra, + }; + if (socket.protocol !== GRAPHQL_TRANSPORT_WS_PROTOCOL) { socket.close(1002, 'Protocol Error'); return async (code, reason) => { @@ -526,13 +533,6 @@ export function makeServer(options: ServerOptions): Server { }; } - const ctx: Context = { - connectionInitReceived: false, - acknowledged: false, - subscriptions: {}, - extra, - }; - // kick the client off (close socket) if the connection has // not been initialised after the specified wait timeout const connectionInitWait =