@nxtedition/lib 14.1.15 → 14.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/undici.js +9 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "14.1.15",
3
+ "version": "14.1.17",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "files": [
package/undici.js CHANGED
@@ -24,6 +24,7 @@ module.exports.request = async function request(
24
24
  method = body ? 'POST' : 'GET',
25
25
  userAgent,
26
26
  headers,
27
+ dump = method === 'HEAD',
27
28
  }
28
29
  ) {
29
30
  if (retry === false) {
@@ -79,8 +80,9 @@ module.exports.request = async function request(
79
80
  try {
80
81
  /* eslint-disable no-unreachable-loop */
81
82
  for (let retryCount = 0; true; retryCount++) {
83
+ let ures
82
84
  try {
83
- const ures = await undici.request(url, {
85
+ ures = await undici.request(url, {
84
86
  method,
85
87
  reset,
86
88
  body,
@@ -96,16 +98,21 @@ module.exports.request = async function request(
96
98
  upstreamLogger?.debug({ ureq, ures }, 'upstream request response')
97
99
 
98
100
  if (ures.statusCode >= 300 && ures.statusCode < 400) {
99
- await ures.body.dump()
100
101
  throw new Error('maxRedirections exceeded')
101
102
  }
102
103
 
103
104
  assert(ures.statusCode >= 200 && ures.statusCode < 300)
104
105
 
106
+ if (dump) {
107
+ await ures.body.dump()
108
+ }
109
+
105
110
  // TODO (fix): Wrap response to handle error that can continue with range request...
106
111
 
107
112
  return ures
108
113
  } catch (err) {
114
+ await ures?.body.dump()
115
+
109
116
  if (retryCount >= maxRetries) {
110
117
  throw err
111
118
  }