@nxtedition/lib 15.0.7 → 15.0.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.
- package/logger.js +11 -7
- package/package.json +1 -1
- package/undici/index.js +5 -0
package/logger.js
CHANGED
|
@@ -12,14 +12,12 @@ module.exports.createLogger = function (
|
|
|
12
12
|
stream = null,
|
|
13
13
|
...options
|
|
14
14
|
} = {},
|
|
15
|
-
onTerminate
|
|
15
|
+
onTerminate,
|
|
16
16
|
) {
|
|
17
17
|
if (!stream) {
|
|
18
|
-
if (
|
|
19
|
-
stream = pino.destination({ fd: 1, sync: true })
|
|
20
|
-
} else if (
|
|
18
|
+
if (
|
|
21
19
|
process.stdout.write !== process.stdout.constructor.prototype.write ||
|
|
22
|
-
|
|
20
|
+
process.stdout.fd == null
|
|
23
21
|
) {
|
|
24
22
|
stream = process.stdout
|
|
25
23
|
}
|
|
@@ -29,8 +27,11 @@ module.exports.createLogger = function (
|
|
|
29
27
|
// Do nothing...
|
|
30
28
|
} else if (!extreme) {
|
|
31
29
|
stream = pino.destination({ fd: process.stdout.fd ?? 1, sync: true })
|
|
30
|
+
} else if (!isMainThread) {
|
|
31
|
+
// TODO (fix): Async logging?
|
|
32
|
+
stream = pino.destination({ fd: 1, sync: true })
|
|
32
33
|
} else {
|
|
33
|
-
stream = pino.destination({
|
|
34
|
+
stream = pino.destination({ sync: false, minLength: 4096 })
|
|
34
35
|
setInterval(() => {
|
|
35
36
|
logger.flush()
|
|
36
37
|
}, flushInterval).unref()
|
|
@@ -45,7 +46,7 @@ module.exports.createLogger = function (
|
|
|
45
46
|
...options.serializers,
|
|
46
47
|
},
|
|
47
48
|
},
|
|
48
|
-
stream
|
|
49
|
+
stream,
|
|
49
50
|
)
|
|
50
51
|
|
|
51
52
|
let called = false
|
|
@@ -60,6 +61,9 @@ module.exports.createLogger = function (
|
|
|
60
61
|
err = new Error(err)
|
|
61
62
|
}
|
|
62
63
|
logger.fatal({ err }, evt || 'error caused exit')
|
|
64
|
+
|
|
65
|
+
process._rawDebug(err.stack)
|
|
66
|
+
|
|
63
67
|
if (stream?.flushSync) {
|
|
64
68
|
stream.flushSync()
|
|
65
69
|
}
|
package/package.json
CHANGED
package/undici/index.js
CHANGED
|
@@ -142,6 +142,7 @@ async function request(urlOrOpts, opts = {}) {
|
|
|
142
142
|
|
|
143
143
|
dispatch(opts, {
|
|
144
144
|
resolve,
|
|
145
|
+
logger: opts.logger,
|
|
145
146
|
/** @type {Function | null} */ abort: null,
|
|
146
147
|
/** @type {stream.Readable | null} */ body: null,
|
|
147
148
|
onConnect(abort) {
|
|
@@ -166,6 +167,10 @@ async function request(urlOrOpts, opts = {}) {
|
|
|
166
167
|
statusMessage,
|
|
167
168
|
headers,
|
|
168
169
|
size: Number.isFinite(contentLength) ? contentLength : null,
|
|
170
|
+
}).on('error', (err) => {
|
|
171
|
+
if (this.logger && this.body?.listenerCount('error') === 1) {
|
|
172
|
+
this.logger.error({ err }, 'unhandled response body error')
|
|
173
|
+
}
|
|
169
174
|
})
|
|
170
175
|
|
|
171
176
|
this.resolve(this.body)
|