Skip to content

Commit

Permalink
support closeOnBackpressureLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Oct 4, 2024
1 parent 86b523d commit a322841
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit a322841

Please sign in to comment.