@nxtedition/nxt-undici 6.3.5 → 6.3.7
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/interceptor/log.js
CHANGED
|
@@ -89,19 +89,24 @@ class Handler extends DecoratorHandler {
|
|
|
89
89
|
onComplete() {
|
|
90
90
|
this.#timing.end = performance.now() - this.#created
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
bytesReadPerSecond: (this.#pos * 1e3) / (this.#timing.end - this.#timing.data),
|
|
100
|
-
},
|
|
101
|
-
elapsedTime: this.#timing.end,
|
|
92
|
+
const data = {
|
|
93
|
+
ures: {
|
|
94
|
+
statusCode: this.#statusCode,
|
|
95
|
+
headers: this.#headers,
|
|
96
|
+
timing: this.#timing,
|
|
97
|
+
bytesRead: this.#pos,
|
|
98
|
+
bytesReadPerSecond: (this.#pos * 1e3) / (this.#timing.end - this.#timing.data),
|
|
102
99
|
},
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
elapsedTime: this.#timing.end,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.#statusCode >= 500) {
|
|
104
|
+
this.#logger.error(data, 'upstream request completed')
|
|
105
|
+
} else if (this.#statusCode >= 400) {
|
|
106
|
+
this.#logger.warn(data, 'upstream request completed')
|
|
107
|
+
} else {
|
|
108
|
+
this.#logger.debug(data, 'upstream request completed')
|
|
109
|
+
}
|
|
105
110
|
|
|
106
111
|
super.onComplete()
|
|
107
112
|
}
|
|
@@ -111,8 +111,8 @@ class Handler extends DecoratorHandler {
|
|
|
111
111
|
|
|
112
112
|
const { start, size, end = size } = range
|
|
113
113
|
|
|
114
|
-
assert(start != null && Number.isFinite(start),
|
|
115
|
-
assert(end != null && Number.isFinite(end),
|
|
114
|
+
assert(start != null && Number.isFinite(start), `invalid content-range start: ${start}`)
|
|
115
|
+
assert(end != null && Number.isFinite(end), `invalid content-length end: ${end}`)
|
|
116
116
|
assert(
|
|
117
117
|
contentLength == null || end == null || contentLength === end - start,
|
|
118
118
|
'content-range mismatch',
|
|
@@ -163,8 +163,11 @@ class Handler extends DecoratorHandler {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
const { start, size, end = size } = contentRange
|
|
166
|
-
assert(this.#pos === start,
|
|
167
|
-
assert(
|
|
166
|
+
assert(this.#pos === start, `content-range mismatched start ${this.#pos} != ${start}`)
|
|
167
|
+
assert(
|
|
168
|
+
this.#end == null || this.#end === end,
|
|
169
|
+
`content-range mismatched end ${this.#end} != ${end}`,
|
|
170
|
+
)
|
|
168
171
|
|
|
169
172
|
this.#resume = resume
|
|
170
173
|
|