@nxtedition/lib 21.0.13 → 21.0.15

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/app.js CHANGED
@@ -6,7 +6,13 @@ import stream from 'node:stream'
6
6
  import { Buffer } from 'node:buffer'
7
7
  import { getDockerSecretsSync } from './docker-secrets.js'
8
8
  import fp from 'lodash/fp.js'
9
- import { isMainThread, parentPort, threadId, BroadcastChannel } from 'node:worker_threads'
9
+ import {
10
+ isMainThread,
11
+ parentPort,
12
+ threadId,
13
+ BroadcastChannel,
14
+ resourceLimits,
15
+ } from 'node:worker_threads'
10
16
  import deepstream from '@nxtedition/deepstream.io-client-js'
11
17
  import { createLogger } from './logger.js'
12
18
  import nconf from 'nconf'
@@ -492,6 +498,7 @@ export function makeApp(appConfig, onTerminate) {
492
498
  cpu,
493
499
  memory,
494
500
  totalMemory,
501
+ resourceLimits,
495
502
  utilization: performance.eventLoopUtilization?.(elu2, elu1),
496
503
  heap: v8.getHeapStatistics(),
497
504
  }
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
- .on('timeout', function () {
80
- this.destroy((reqTimeoutError ??= new createError.RequestTimeout()))
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', function () {
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
- reqLogger.debug('request closed')
97
+ this.log.debug('request closed')
96
98
  resolve(null)
97
99
  ac.abort()
98
100
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "21.0.13",
3
+ "version": "21.0.15",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/serializers.js CHANGED
@@ -192,6 +192,7 @@ function errSerializer(err) {
192
192
  const _err = Object.create(pinoErrProto)
193
193
  _err.type =
194
194
  toString.call(err.constructor) === '[object Function]' ? err.constructor.name : err.name
195
+ _err.name = err.name
195
196
  _err.message = err.message
196
197
  _err.stack = err.stack
197
198
 
@@ -210,7 +211,7 @@ function errSerializer(err) {
210
211
  if (!Object.prototype.hasOwnProperty.call(val, seen)) {
211
212
  _err[key] = errSerializer(val)
212
213
  }
213
- } else if (val != null && key[0] !== key[0].toUpperCase()) {
214
+ } else if (val != null && !/^[A-Z0-9_]+$/.test(key)) {
214
215
  _err[key] = val
215
216
  }
216
217
  }