@nxtedition/nxt-undici 2.2.4 → 2.2.5

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/lib/utils.js +5 -9
  2. package/package.json +1 -1
package/lib/utils.js CHANGED
@@ -70,17 +70,13 @@ export function parseContentRange(range) {
70
70
  return { start, end: end ? end + 1 : size, size }
71
71
  }
72
72
 
73
- export function retry(err, retryCount, opts) {
73
+ export async function retry(err, retryCount, opts) {
74
74
  if (!opts) {
75
- return null
75
+ throw err
76
76
  }
77
77
 
78
78
  if (typeof opts === 'function') {
79
- try {
80
- return opts(err, retryCount, opts, (opts) => retry(err, retryCount, opts))
81
- } catch (err) {
82
- return Promise.reject(err)
83
- }
79
+ return opts(err, retryCount, opts, (opts) => retry(err, retryCount, opts))
84
80
  }
85
81
 
86
82
  if (typeof opts === 'number') {
@@ -90,7 +86,7 @@ export function retry(err, retryCount, opts) {
90
86
  const retryMax = opts?.count ?? 8
91
87
 
92
88
  if (retryCount > retryMax) {
93
- return null
89
+ throw err
94
90
  }
95
91
 
96
92
  const statusCode = err.statusCode ?? err.status ?? err.$metadata?.httpStatusCode ?? null
@@ -125,7 +121,7 @@ export function retry(err, retryCount, opts) {
125
121
  return tp.setTimeout(Math.min(10e3, retryCount * 1e3), undefined, { signal: opts.signal })
126
122
  }
127
123
 
128
- return null
124
+ throw err
129
125
  }
130
126
 
131
127
  export function parseURL(url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",