@nxtedition/nxt-undici 4.2.15 → 4.2.17

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/index.js CHANGED
@@ -36,9 +36,9 @@ function wrapDispatcher(dispatcher) {
36
36
  interceptors.requestId(),
37
37
  interceptors.responseRetry(),
38
38
  interceptors.responseVerify(),
39
+ interceptors.proxy(),
39
40
  interceptors.cache(),
40
41
  interceptors.redirect(),
41
- interceptors.proxy(),
42
42
  (dispatch) => (opts, handler) => {
43
43
  const headers = parseHeaders(opts.headers)
44
44
 
@@ -59,8 +59,8 @@ function wrapDispatcher(dispatcher) {
59
59
  query: opts.query,
60
60
  headers,
61
61
  signal: opts.signal,
62
- reset: opts.reset ?? false,
63
- blocking: opts.blocking ?? false,
62
+ reset: opts.reset ?? null,
63
+ blocking: opts.blocking ?? null,
64
64
  headersTimeout: opts.headersTimeout,
65
65
  bodyTimeout: opts.bodyTimeout,
66
66
  idempotent: opts.idempotent,
@@ -72,7 +72,7 @@ function wrapDispatcher(dispatcher) {
72
72
  error: opts.error ?? true,
73
73
  verify: opts.verify ?? true,
74
74
  logger: opts.logger ?? null,
75
- dns: opts.dns ?? true,
75
+ dns: opts.dns ?? false,
76
76
  connect: opts.connect,
77
77
  lookup: opts.lookup ?? defaultLookup,
78
78
  maxRedirections: 0, // TODO (fix): Ugly hack to disable undici redirections.
@@ -72,18 +72,11 @@ class Handler extends DecoratorHandler {
72
72
  const stackTraceLimit = Error.stackTraceLimit
73
73
  Error.stackTraceLimit = 0
74
74
  try {
75
- err = Object.assign(createHttpError(this.#statusCode), {
76
- url: new URL(this.#opts.path, this.#opts.origin).href,
77
- reason: this.#body?.reason,
78
- code: this.#body?.code,
79
- error: this.#body?.error,
80
- headers: this.#headers,
81
- body: this.#body,
82
- })
75
+ err = createHttpError(this.#statusCode)
83
76
  } finally {
84
77
  Error.stackTraceLimit = stackTraceLimit
85
78
  }
86
- this.#handler.onError(err)
79
+ this.#handler.onError(this.#decorateError(err))
87
80
  } else {
88
81
  this.#handler.onComplete(rawTrailers)
89
82
  }
@@ -93,9 +86,20 @@ class Handler extends DecoratorHandler {
93
86
  if (this.#errored) {
94
87
  // Do nothing...
95
88
  } else {
96
- this.#handler.onError(err)
89
+ this.#handler.onError(this.#decorateError(err))
97
90
  }
98
91
  }
92
+
93
+ #decorateError(err) {
94
+ Object.assign(err, {
95
+ url: new URL(this.#opts.path, this.#opts.origin).href,
96
+ headers: this.#headers,
97
+ reason: this.#body?.reason,
98
+ code: this.#body?.code,
99
+ error: this.#body?.error,
100
+ body: typeof this.#body !== 'string' || this.#body.length < 1024 ? this.#body : undefined,
101
+ })
102
+ }
99
103
  }
100
104
 
101
105
  export default (opts) => (dispatch) => (opts, handler) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "4.2.15",
3
+ "version": "4.2.17",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^22.7.4",
19
- "eslint": "^9.12.0",
19
+ "eslint": "^8.0.0",
20
20
  "eslint-config-prettier": "^9.1.0",
21
21
  "eslint-config-standard": "^17.0.0",
22
22
  "eslint-plugin-import": "^2.31.0",