@nxtedition/lib 21.0.12 → 21.0.14
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/http.js +13 -11
- package/package.json +1 -1
- package/s3.js +4 -2
- package/serializers.js +2 -3
package/http.js
CHANGED
|
@@ -27,6 +27,14 @@ export function genReqId() {
|
|
|
27
27
|
let reqTimeoutError
|
|
28
28
|
let resTimeoutError
|
|
29
29
|
|
|
30
|
+
function onRequestTimeout() {
|
|
31
|
+
this.destroy((reqTimeoutError ??= new createError.RequestTimeout()))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function onResponseTimeout() {
|
|
35
|
+
this.destroy((resTimeoutError ??= new createError.RequestTimeout()))
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
export async function request(ctx, next) {
|
|
31
39
|
const { req, res, logger } = ctx
|
|
32
40
|
const startTime = performance.now()
|
|
@@ -75,24 +83,18 @@ export async function request(ctx, next) {
|
|
|
75
83
|
await Promise.all([
|
|
76
84
|
next(),
|
|
77
85
|
new Promise((resolve, reject) => {
|
|
78
|
-
req
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
})
|
|
82
|
-
.on('error', function (err) {
|
|
83
|
-
this.log.error({ err }, 'request error')
|
|
84
|
-
})
|
|
86
|
+
req.on('timeout', onRequestTimeout).on('error', function (err) {
|
|
87
|
+
reject(err)
|
|
88
|
+
})
|
|
85
89
|
res
|
|
86
|
-
.on('timeout',
|
|
87
|
-
this.destroy((resTimeoutError ??= new createError.RequestTimeout()))
|
|
88
|
-
})
|
|
90
|
+
.on('timeout', onResponseTimeout)
|
|
89
91
|
.on('error', function (err) {
|
|
90
92
|
reject(err)
|
|
91
93
|
})
|
|
92
94
|
// TODO (fix): Use 'end' once we can trust that
|
|
93
95
|
// 'end' or 'error' will always be emitted.
|
|
94
96
|
.on('close', function () {
|
|
95
|
-
|
|
97
|
+
this.log.debug('request closed')
|
|
96
98
|
resolve(null)
|
|
97
99
|
ac.abort()
|
|
98
100
|
})
|
package/package.json
CHANGED
package/s3.js
CHANGED
|
@@ -204,9 +204,11 @@ export async function upload({
|
|
|
204
204
|
} catch (err) {
|
|
205
205
|
logger?.warn({ err }, 'part upload failed')
|
|
206
206
|
|
|
207
|
-
if (retryCount <
|
|
207
|
+
if (retryCount < 16) {
|
|
208
208
|
logger?.debug({ retryCount }, 'part upload retry')
|
|
209
|
-
await tp.setTimeout(1e3, undefined, {
|
|
209
|
+
await tp.setTimeout(retryCount * retryCount * 1e3, undefined, {
|
|
210
|
+
signal: uploader.signal,
|
|
211
|
+
})
|
|
210
212
|
} else {
|
|
211
213
|
uploader.ac.abort(err)
|
|
212
214
|
return { error: err }
|
package/serializers.js
CHANGED
|
@@ -35,8 +35,6 @@ function getTiming(obj) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export default {
|
|
38
|
-
data: (data) =>
|
|
39
|
-
data != null && typeof data === 'object' ? JSON.stringify(data, undefined, 2) : data,
|
|
40
38
|
err: (err) => errSerializer(err),
|
|
41
39
|
socket: (socket) =>
|
|
42
40
|
socket && {
|
|
@@ -194,6 +192,7 @@ function errSerializer(err) {
|
|
|
194
192
|
const _err = Object.create(pinoErrProto)
|
|
195
193
|
_err.type =
|
|
196
194
|
toString.call(err.constructor) === '[object Function]' ? err.constructor.name : err.name
|
|
195
|
+
_err.name = err.name
|
|
197
196
|
_err.message = err.message
|
|
198
197
|
_err.stack = err.stack
|
|
199
198
|
|
|
@@ -212,7 +211,7 @@ function errSerializer(err) {
|
|
|
212
211
|
if (!Object.prototype.hasOwnProperty.call(val, seen)) {
|
|
213
212
|
_err[key] = errSerializer(val)
|
|
214
213
|
}
|
|
215
|
-
} else if (val != null &&
|
|
214
|
+
} else if (val != null && !/^[A-Z0-9_]+$/.test(key)) {
|
|
216
215
|
_err[key] = val
|
|
217
216
|
}
|
|
218
217
|
}
|