@nxtedition/lib 15.0.39 → 15.0.41
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 +14 -7
- package/logger.js +1 -1
- package/package.json +1 -1
package/http.js
CHANGED
|
@@ -45,6 +45,10 @@ module.exports.request = async function request(ctx, next) {
|
|
|
45
45
|
ctx.method = req.method
|
|
46
46
|
ctx.query = ctx.url.search ? querystring.parse(ctx.url.search.slice(1)) : {}
|
|
47
47
|
|
|
48
|
+
if (req.method === 'GET' || req.method === 'HEAD') {
|
|
49
|
+
req.resume() // Dump the body if there is one.
|
|
50
|
+
}
|
|
51
|
+
|
|
48
52
|
res.setHeader('request-id', req.id)
|
|
49
53
|
|
|
50
54
|
const isHealthcheck = ctx.url.pathname === '/healthcheck'
|
|
@@ -99,7 +103,7 @@ module.exports.request = async function request(ctx, next) {
|
|
|
99
103
|
reqLogger.warn({ err }, 'request error')
|
|
100
104
|
})
|
|
101
105
|
|
|
102
|
-
if (!
|
|
106
|
+
if (!res.headersSent && !res.destroyed) {
|
|
103
107
|
res.statusCode = err.statusCode || 500
|
|
104
108
|
|
|
105
109
|
let reqId = req?.id || err.id
|
|
@@ -140,16 +144,19 @@ module.exports.request = async function request(ctx, next) {
|
|
|
140
144
|
} else {
|
|
141
145
|
reqLogger = reqLogger.child({ res, err, responseTime })
|
|
142
146
|
if (req.aborted || err.name === 'AbortError') {
|
|
143
|
-
reqLogger.debug('request aborted')
|
|
147
|
+
reqLogger.debug({ err }, 'request aborted')
|
|
144
148
|
} else if (err.statusCode < 500) {
|
|
145
|
-
reqLogger.warn('request failed')
|
|
149
|
+
reqLogger.warn({ err }, 'request failed')
|
|
146
150
|
} else {
|
|
147
|
-
reqLogger.error('request error')
|
|
151
|
+
reqLogger.error({ err }, 'request error')
|
|
148
152
|
}
|
|
149
153
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
if (res.writableEnded) {
|
|
155
|
+
reqLogger.debug('response completed')
|
|
156
|
+
} else {
|
|
157
|
+
reqLogger.debug('response destroyed')
|
|
158
|
+
res.destroy()
|
|
159
|
+
}
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
162
|
}
|
package/logger.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports.createLogger = function (
|
|
|
24
24
|
} else if (!isMainThread) {
|
|
25
25
|
stream = pino.destination({ fd: 1, sync: false, minLength: 0 })
|
|
26
26
|
} else {
|
|
27
|
-
stream = pino.destination({ sync: false, minLength:
|
|
27
|
+
stream = pino.destination({ sync: false, minLength: 8 * 1024, maxWrite: 32 * 1024 })
|
|
28
28
|
|
|
29
29
|
let flushing = 0
|
|
30
30
|
setInterval(() => {
|