Skip to content

Commit

Permalink
fix(server): Hide internal server error messages from the client in p…
Browse files Browse the repository at this point in the history
…roduction

Closes: enisdenjo#31
  • Loading branch information
enisdenjo committed Oct 20, 2020
1 parent 50a7e0f commit 36fe405
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/server.ts
Expand Up @@ -220,6 +220,8 @@ export function createServer(
options: ServerOptions,
websocketOptionsOrServer: WebSocketServerOptions | WebSocketServer,
): Server {
const isProd = process.env.NODE_ENV === 'production';

const {
schema,
context,
Expand Down Expand Up @@ -315,9 +317,11 @@ export function createServer(
}

if (isErrorEvent(errorOrClose)) {
// TODO-db-200805 leaking sensitive information by sending the error message too?
// 1011: Internal Error
ctxRef.current.socket.close(1011, errorOrClose.message);
ctxRef.current.socket.close(
1011,
isProd ? 'Internal Error' : errorOrClose.message,
);
}

Object.entries(ctxRef.current.subscriptions).forEach(
Expand Down

0 comments on commit 36fe405

Please sign in to comment.