Skip to content

Commit

Permalink
fix EVERY FAILURE!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev committed May 20, 2024
1 parent f24467b commit eab6f93
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lib/web/websocket/permessage-deflate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class PerMessageDeflate {
#options = {}

constructor (extensions) {
this.#options.clientNoContextTakeover = extensions.has('client_no_context_takeover')
this.#options.clientMaxWindowBits = extensions.get('client_max_window_bits')
this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
}

decompress (chunk, fin, callback) {
Expand All @@ -27,13 +27,13 @@ class PerMessageDeflate {
if (!this.#inflate) {
let windowBits = Z_DEFAULT_WINDOWBITS

if (this.#options.clientMaxWindowBits) { // empty values default to Z_DEFAULT_WINDOWBITS
if (!isValidClientWindowBits(this.#options.clientMaxWindowBits)) {
callback(new Error('Invalid client_max_window_bits'))
if (this.#options.serverMaxWindowBits) { // empty values default to Z_DEFAULT_WINDOWBITS
if (!isValidClientWindowBits(this.#options.serverMaxWindowBits)) {
callback(new Error('Invalid server_max_window_bits'))
return
}

windowBits = Number.parseInt(this.#options.clientMaxWindowBits)
windowBits = Number.parseInt(this.#options.serverMaxWindowBits)
}

this.#inflate = createInflateRaw({ windowBits })
Expand All @@ -45,7 +45,10 @@ class PerMessageDeflate {
this.#inflate[kLength] += data.length
})

this.#inflate.on('error', (err) => callback(err))
this.#inflate.on('error', (err) => {
this.#inflate = null
callback(err)
})
}

this.#inflate.write(chunk)
Expand All @@ -60,10 +63,6 @@ class PerMessageDeflate {
this.#inflate[kLength] = 0

callback(null, full)

if (fin && this.#options.clientNoContextTakeover) {
// this.#inflate.reset()
}
})
}
}
Expand Down

0 comments on commit eab6f93

Please sign in to comment.