From a322841b405f308b61cafcdef67b63cd3c1b998b Mon Sep 17 00:00:00 2001 From: dimden <26517362+dimdenGD@users.noreply.github.com> Date: Sat, 5 Oct 2024 02:50:57 +0300 Subject: [PATCH] support closeOnBackpressureLimit --- README.md | 1 + src/server.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index efccac4..837718f 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ Below is the list of supported features and their compatibility: - ✅ maxBackpressure (uWS only, default `maxPayload`) - ✅ idleTimeout (uWS only, default 120) - ✅ maxLifetime (uWS only, default 0) +- ✅ closeOnBackpressureLimit (uWS only, default `false`) #### Server events diff --git a/src/server.js b/src/server.js index 44ff244..e505b05 100644 --- a/src/server.js +++ b/src/server.js @@ -50,6 +50,9 @@ module.exports = class WebSocketServer extends EventEmitter { if(typeof options.WebSocket === 'undefined') { options.WebSocket = WebSocket; } + if(typeof options.closeOnBackpressureLimit === 'undefined') { + options.closeOnBackpressureLimit = false; + } if(options.clientTracking) { this.clients = new Set(); @@ -77,6 +80,7 @@ module.exports = class WebSocketServer extends EventEmitter { maxBackpressure: this.options.maxBackpressure ?? this.options.maxPayload, idleTimeout: this.options.idleTimeout ?? 120, maxLifetime: this.options.maxLifetime ?? 0, + closeOnBackpressureLimit: this.options.closeOnBackpressureLimit, compression: typeof this.options.perMessageDeflate !== 'number' && this.options.perMessageDeflate ? (uWS.DEDICATED_COMPRESSOR_4KB | uWS.DEDICATED_DECOMPRESSOR) : this.options.perMessageDeflate, upgrade: async (res, req, context) => {