@nxtedition/nxt-undici 4.2.9 → 4.2.10

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.
@@ -8,8 +8,9 @@ class Handler extends DecoratorHandler {
8
8
  #abort = null
9
9
  #aborted = false
10
10
  #pos = 0
11
+ #now = 0
11
12
  #timing = {
12
- created: performance.now(),
13
+ created: -1,
13
14
  connect: -1,
14
15
  headers: -1,
15
16
  data: -1,
@@ -23,12 +24,17 @@ class Handler extends DecoratorHandler {
23
24
  this.#handler = handler
24
25
  this.#opts = opts
25
26
  this.#logger = opts.logger.child({ ureq: { id: opts.id } })
27
+
28
+ this.#timing.created = performance.now()
29
+ this.#now += this.#timing.created
26
30
  }
27
31
 
28
32
  onConnect(abort) {
29
33
  this.#pos = 0
30
34
  this.#abort = abort
31
- this.#timing.connect = performance.now() - this.#timing.created
35
+
36
+ this.#timing.connect = performance.now() - this.#now
37
+ this.#now += this.#timing.connect
32
38
 
33
39
  this.#logger.debug({ ureq: this.#opts }, 'upstream request started')
34
40
 
@@ -48,7 +54,8 @@ class Handler extends DecoratorHandler {
48
54
  }
49
55
 
50
56
  onHeaders(statusCode, rawHeaders, resume, statusMessage, headers = parseHeaders(rawHeaders)) {
51
- this.#timing.headers = performance.now() - this.#timing.connect - this.#timing.created
57
+ this.#timing.headers = performance.now() - this.#now
58
+ this.#now += this.#timing.headers
52
59
 
53
60
  this.#logger = this.#logger.child({ ures: { statusCode, headers } })
54
61
  this.#logger.debug({ elapsedTime: this.#timing.headers }, 'upstream request response')
@@ -58,7 +65,8 @@ class Handler extends DecoratorHandler {
58
65
 
59
66
  onData(chunk) {
60
67
  if (this.#timing.data === -1) {
61
- this.#timing.data = performance.now() - this.#timing.headers - this.#timing.created
68
+ this.#timing.data = performance.now() - this.#now
69
+ this.#now += this.#timing.data
62
70
  }
63
71
 
64
72
  this.#pos += chunk.length
@@ -67,7 +75,8 @@ class Handler extends DecoratorHandler {
67
75
  }
68
76
 
69
77
  onComplete(rawTrailers) {
70
- this.#timing.complete = performance.now() - this.#timing.data - this.#timing.created
78
+ this.#timing.complete = performance.now() - this.#now
79
+ this.#now += this.#timing.complete
71
80
 
72
81
  this.#logger.debug(
73
82
  {
@@ -83,7 +92,8 @@ class Handler extends DecoratorHandler {
83
92
  }
84
93
 
85
94
  onError(err) {
86
- this.#timing.error = performance.now() - this.#timing.data - this.#timing.created
95
+ this.#timing.error = performance.now() - this.#now
96
+ this.#now += this.#timing.error
87
97
 
88
98
  if (this.#aborted) {
89
99
  this.#logger.debug(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "4.2.9",
3
+ "version": "4.2.10",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",