@nxtedition/nxt-undici 6.2.14 → 6.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ class Handler extends DecoratorHandler {
18
18
  #headers
19
19
  #trailers
20
20
  #body
21
+ #bodySize = 0
21
22
 
22
23
  #abort
23
24
  #aborted = false
@@ -48,6 +49,7 @@ class Handler extends DecoratorHandler {
48
49
  this.#statusCode = 0
49
50
  this.#headers = null
50
51
  this.#body = null
52
+ this.#bodySize = 0
51
53
  this.#trailers = null
52
54
 
53
55
  if (!this.#headersSent) {
@@ -121,6 +123,7 @@ class Handler extends DecoratorHandler {
121
123
  this.#etag = headers.etag
122
124
  } else if (statusCode >= 400) {
123
125
  this.#body = []
126
+ this.#bodySize = 0
124
127
  return true
125
128
  } else {
126
129
  this.#headersSent = true
@@ -177,7 +180,14 @@ class Handler extends DecoratorHandler {
177
180
  return super.onData(chunk)
178
181
  }
179
182
 
180
- this.#body?.push(chunk)
183
+ if (this.#body) {
184
+ this.#body.push(chunk)
185
+ this.#bodySize += chunk.byteLength
186
+ if (this.#bodySize > 256 * 1024) {
187
+ this.#body = null
188
+ this.#bodySize = 0
189
+ }
190
+ }
181
191
  }
182
192
 
183
193
  onComplete(trailers) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "6.2.14",
3
+ "version": "6.2.15",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",