Skip to content

Commit

Permalink
feat(protocols): add logging socket closing
Browse files Browse the repository at this point in the history
  • Loading branch information
inkedsquid committed Nov 26, 2024
1 parent fd4991f commit 5da5930
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/core/network/protocols/httpwsProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,26 @@ class HttpWsProtocol extends Protocol {
return;
}

const reason = Buffer.from(message || "").toString();

// This hack is only here to indicate that uWebSockets killed the connection early
// because the received payload exceeded the configured threshold.
if (
code === 1006 &&
typeof reason === "string" &&
reason.startsWith("Received too big message")
) {
global.kuzzle.log.error(
`[${connection.id}] connection closed: payload exceeded the threshold`,
);
}

if (debugWS.enabled) {
debugWS(
"[%s] received a `close` event (CODE: %d, REASON: %s)",
connection.id,
code,
Buffer.from(message || "").toString(),
reason,
);
}
this.entryPoint.removeConnection(connection.id);
Expand Down

0 comments on commit 5da5930

Please sign in to comment.