Skip to content

Commit

Permalink
fix(server): Init context first on connection open
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed May 18, 2021
1 parent 50caba1 commit a80e753
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,13 @@ export function makeServer<E = unknown>(options: ServerOptions<E>): Server<E> {

return {
opened(socket, extra) {
const ctx: Context<E> = {
connectionInitReceived: false,
acknowledged: false,
subscriptions: {},
extra,
};

if (socket.protocol !== GRAPHQL_TRANSPORT_WS_PROTOCOL) {
socket.close(1002, 'Protocol Error');
return async (code, reason) => {
Expand All @@ -526,13 +533,6 @@ export function makeServer<E = unknown>(options: ServerOptions<E>): Server<E> {
};
}

const ctx: Context<E> = {
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 =
Expand Down

0 comments on commit a80e753

Please sign in to comment.