@nxtedition/nxt-undici 7.3.15 → 7.3.17

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.
@@ -45,17 +45,14 @@ export default () => (dispatch) => {
45
45
  resolve([err, null])
46
46
  } else {
47
47
  const now = getFastNow()
48
- const prev = cache.get(hostname)
49
- const prevByAddr = prev ? new Map(prev.map((r) => [r.address, r])) : null
50
48
  const val = records.map(({ address }) => {
51
- const old = prevByAddr?.get(address)
52
49
  return {
53
50
  address,
54
51
  expires: now + (ttl ?? 1e3),
55
52
  pending: 0,
56
- errored: old ? old.errored : 0,
53
+ errored: 0,
57
54
  counter: 0,
58
- timeout: old ? old.timeout : 0,
55
+ timeout: 0,
59
56
  }
60
57
  })
61
58
 
@@ -134,6 +131,7 @@ export default () => (dispatch) => {
134
131
  if (!record) {
135
132
  throw Object.assign(new Error(`No available DNS records found for ${hostname}`), {
136
133
  code: 'ENOTFOUND',
134
+ data: { records },
137
135
  })
138
136
  }
139
137
 
@@ -1,5 +1,8 @@
1
1
  import { DecoratorHandler } from '../utils.js'
2
2
 
3
+ const kGlobalIndex = Symbol('globalIndex')
4
+ const kGlobalArray = Symbol('globalArray')
5
+
3
6
  class Handler extends DecoratorHandler {
4
7
  #opts
5
8
  #logger
@@ -19,9 +22,6 @@ class Handler extends DecoratorHandler {
19
22
  #statusCode
20
23
  #headers
21
24
 
22
- #globalIndex = -1
23
- #globalArray = (globalThis.__undici_requests ??= [])
24
-
25
25
  constructor(logOpts, opts, { handler }) {
26
26
  super(handler)
27
27
 
@@ -35,7 +35,8 @@ class Handler extends DecoratorHandler {
35
35
  this.#logger.debug('upstream request started')
36
36
  this.#timing.created = this.#created + performance.timeOrigin
37
37
 
38
- this.#globalIndex = this.#globalArray.push(this) - 1
38
+ this[kGlobalArray] = globalThis.__undici_requests ??= []
39
+ this[kGlobalIndex] = this[kGlobalArray].push(this) - 1
39
40
  }
40
41
 
41
42
  onConnect(abort) {
@@ -151,13 +152,13 @@ class Handler extends DecoratorHandler {
151
152
  }
152
153
 
153
154
  onDone() {
154
- if (this.#globalIndex !== -1) {
155
- const tmp = this.#globalArray.pop()
155
+ if (this[kGlobalIndex] !== -1) {
156
+ const tmp = this[kGlobalArray].pop()
156
157
  if (tmp !== this) {
157
- this.#globalArray[this.#globalIndex] = tmp
158
- tmp.#globalIndex = this.#globalIndex
158
+ this[kGlobalArray][this[kGlobalIndex]] = tmp
159
+ tmp[kGlobalIndex] = this[kGlobalIndex]
159
160
  }
160
- this.#globalIndex = -1
161
+ this[kGlobalIndex] = -1
161
162
  }
162
163
  }
163
164
  }
@@ -47,13 +47,17 @@ export default () => (dispatch) => {
47
47
  schedulers.set(opts.origin, scheduler)
48
48
  }
49
49
 
50
- scheduler.acquire(() => {
51
- const priorityHandler = new Handler(handler, scheduler)
52
- try {
53
- dispatch(opts, priorityHandler)
54
- } catch (err) {
55
- priorityHandler.onError(err)
56
- }
57
- }, opts.priority)
50
+ const priorityHandler = new Handler(handler, scheduler)
51
+ scheduler.acquire(
52
+ (priorityHandler) => {
53
+ try {
54
+ dispatch(opts, priorityHandler)
55
+ } catch (err) {
56
+ priorityHandler.onError(err)
57
+ }
58
+ },
59
+ opts.priority,
60
+ priorityHandler,
61
+ )
58
62
  }
59
63
  }
@@ -177,6 +177,11 @@ class Handler extends DecoratorHandler {
177
177
  onData(chunk) {
178
178
  if (this.#pos != null) {
179
179
  this.#pos += chunk.byteLength
180
+
181
+ if (this.#end != null && this.#pos > this.#end) {
182
+ this.#maybeError(new Error('Response body exceeded Content-Range'))
183
+ return false
184
+ }
180
185
  }
181
186
 
182
187
  if (this.#statusCode < 400) {
@@ -197,6 +202,10 @@ class Handler extends DecoratorHandler {
197
202
  this.#trailers = trailers
198
203
 
199
204
  if (this.#statusCode < 400) {
205
+ if (this.#end != null && this.#pos !== this.#end) {
206
+ this.#maybeError(new Error('Response body length mismatch with Content-Range'))
207
+ return
208
+ }
200
209
  return super.onComplete(trailers)
201
210
  }
202
211
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "7.3.15",
3
+ "version": "7.3.17",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",
@@ -9,8 +9,8 @@
9
9
  "lib/*"
10
10
  ],
11
11
  "dependencies": {
12
- "@nxtedition/scheduler": "^3.0.8",
13
- "@nxtedition/undici": "^11.1.3",
12
+ "@nxtedition/scheduler": "^4.1.1",
13
+ "@nxtedition/undici": "^11.1.4",
14
14
  "cache-control-parser": "^2.2.0",
15
15
  "fast-querystring": "^1.1.2",
16
16
  "http-errors": "^2.0.1",
@@ -18,17 +18,17 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@eslint/js": "^10.0.1",
21
- "@types/node": "^25.2.3",
22
- "eslint": "^10.0.0",
21
+ "@types/node": "^25.5.2",
22
+ "eslint": "^10.2.0",
23
23
  "eslint-plugin-n": "^17.24.0",
24
24
  "husky": "^9.1.7",
25
- "lint-staged": "^16.2.7",
26
- "pino": "^9.6.0",
25
+ "lint-staged": "^16.4.0",
26
+ "pino": "^10.3.1",
27
27
  "pinst": "^3.0.0",
28
28
  "prettier": "^3.8.1",
29
29
  "send": "^1.2.1",
30
- "tap": "^21.5.1",
31
- "undici-types": "^7.22.0"
30
+ "tap": "^21.6.3",
31
+ "undici-types": "^8.0.2"
32
32
  },
33
33
  "scripts": {
34
34
  "prepare": "husky",