@nxtedition/nxt-undici 7.2.2 → 7.2.4

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.
package/lib/index.js CHANGED
@@ -124,6 +124,16 @@ function wrapDispatch(dispatcher) {
124
124
  throw new TypeError('invalid opts.priority')
125
125
  }
126
126
 
127
+ if (priority == null && headers['nxt-priority']) {
128
+ if (headers['nxt-priority'] === 'low' || headers['nxt-priority'] === '0') {
129
+ priority = 0
130
+ } else if (headers['nxt-priority'] === 'normal' || headers['nxt-priority'] === '1') {
131
+ priority = 1
132
+ } else if (headers['nxt-priority'] === 'high' || headers['nxt-priority'] === '2') {
133
+ priority = 2
134
+ }
135
+ }
136
+
127
137
  if (globalThis.__nxt_undici_global_headers) {
128
138
  Object.assign(headers, globalThis.__nxt_undici_global_headers)
129
139
  }
@@ -2,11 +2,11 @@ import { Scheduler } from '@nxtedition/scheduler'
2
2
  import { DecoratorHandler } from '../utils.js'
3
3
 
4
4
  class Handler extends DecoratorHandler {
5
- #next
5
+ #scheduler
6
6
 
7
- constructor(handler, next) {
7
+ constructor(handler, scheduler) {
8
8
  super(handler)
9
- this.#next = next
9
+ this.#scheduler = scheduler
10
10
  }
11
11
 
12
12
  onConnect(abort) {
@@ -25,10 +25,10 @@ class Handler extends DecoratorHandler {
25
25
  }
26
26
 
27
27
  #release() {
28
- if (this.#next) {
29
- const next = this.#next
30
- this.#next = null
31
- next()
28
+ if (this.#scheduler) {
29
+ const scheduler = this.#scheduler
30
+ this.#scheduler = null
31
+ scheduler.release()
32
32
  }
33
33
  }
34
34
  }
@@ -47,11 +47,11 @@ export default () => (dispatch) => {
47
47
  schedulers.set(opts.origin, scheduler)
48
48
  }
49
49
 
50
- scheduler.schedule((next) => {
50
+ scheduler.acquire(() => {
51
51
  try {
52
- dispatch(opts, new Handler(handler, next))
52
+ dispatch(opts, new Handler(handler, scheduler))
53
53
  } catch (err) {
54
- next()
54
+ scheduler.release()
55
55
  handler.onError(err)
56
56
  }
57
57
  }, opts.priority)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "7.2.2",
3
+ "version": "7.2.4",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",
@@ -9,7 +9,7 @@
9
9
  "lib/*"
10
10
  ],
11
11
  "dependencies": {
12
- "@nxtedition/scheduler": "^1.0.5",
12
+ "@nxtedition/scheduler": "^2.0.1",
13
13
  "@nxtedition/undici": "^11.1.1",
14
14
  "cache-control-parser": "^2.0.6",
15
15
  "fast-querystring": "^1.1.2",