@nxtedition/nxt-undici 1.0.3 → 1.0.4
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.
|
@@ -10,7 +10,9 @@ class Handler {
|
|
|
10
10
|
this.aborted = false
|
|
11
11
|
this.reason = null
|
|
12
12
|
|
|
13
|
-
this.
|
|
13
|
+
this.retryCount = 0
|
|
14
|
+
this.retryPromise = null
|
|
15
|
+
|
|
14
16
|
this.pos = 0
|
|
15
17
|
this.end = null
|
|
16
18
|
this.error = null
|
|
@@ -110,31 +112,30 @@ class Handler {
|
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
onError(err) {
|
|
113
|
-
if (this.timeout) {
|
|
114
|
-
clearTimeout(this.timeout)
|
|
115
|
-
this.timeout = null
|
|
116
|
-
}
|
|
117
|
-
|
|
118
115
|
if (!this.resume || this.aborted || !this.etag || isDisturbed(this.opts.body)) {
|
|
119
116
|
return this.handler.onError(err)
|
|
120
117
|
}
|
|
121
118
|
|
|
122
|
-
|
|
119
|
+
// TODO (fix): abort signal?
|
|
120
|
+
const retryPromise = retryFn(err, this.retryCount++, this.opts)
|
|
123
121
|
if (retryPromise == null) {
|
|
124
122
|
return this.handler.onError(err)
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
retryPromise
|
|
128
126
|
.then(() => {
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
if (!this.aborted) {
|
|
128
|
+
try {
|
|
129
|
+
this.dispatch(this.opts, this)
|
|
130
|
+
} catch (err2) {
|
|
131
|
+
this.handler.onError(new AggregateError([err, err2]))
|
|
132
|
+
}
|
|
134
133
|
}
|
|
135
134
|
})
|
|
136
135
|
.catch((err) => {
|
|
137
|
-
this.
|
|
136
|
+
if (!this.aborted) {
|
|
137
|
+
this.handler.onError(err)
|
|
138
|
+
}
|
|
138
139
|
})
|
|
139
140
|
|
|
140
141
|
this.error = err
|
|
@@ -8,9 +8,9 @@ class Handler {
|
|
|
8
8
|
this.abort = null
|
|
9
9
|
this.aborted = false
|
|
10
10
|
this.reason = null
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
11
|
+
|
|
12
|
+
this.retryCount = 0
|
|
13
|
+
this.retryPromise = null
|
|
14
14
|
|
|
15
15
|
this.handler.onConnect((reason) => {
|
|
16
16
|
this.aborted = true
|
|
@@ -52,31 +52,30 @@ class Handler {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
onError(err) {
|
|
55
|
-
if (this.timeout) {
|
|
56
|
-
clearTimeout(this.timeout)
|
|
57
|
-
this.timeout = null
|
|
58
|
-
}
|
|
59
|
-
|
|
60
55
|
if (this.aborted || isDisturbed(this.opts.body)) {
|
|
61
56
|
return this.handler.onError(err)
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
|
|
59
|
+
// TODO (fix): abort signal?
|
|
60
|
+
const retryPromise = retryFn(err, this.retryCount++, this.opts)
|
|
65
61
|
if (retryPromise == null) {
|
|
66
62
|
return this.handler.onError(err)
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
retryPromise
|
|
70
66
|
.then(() => {
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
if (!this.aborted) {
|
|
68
|
+
try {
|
|
69
|
+
this.dispatch(this.opts, this)
|
|
70
|
+
} catch (err2) {
|
|
71
|
+
this.handler.onError(new AggregateError([err, err2]))
|
|
72
|
+
}
|
|
76
73
|
}
|
|
77
74
|
})
|
|
78
75
|
.catch((err) => {
|
|
79
|
-
this.
|
|
76
|
+
if (!this.aborted) {
|
|
77
|
+
this.handler.onError(err)
|
|
78
|
+
}
|
|
80
79
|
})
|
|
81
80
|
|
|
82
81
|
this.opts.logger?.debug('retrying response')
|
|
@@ -10,8 +10,7 @@ class Handler {
|
|
|
10
10
|
this.aborted = false
|
|
11
11
|
this.reason = null
|
|
12
12
|
|
|
13
|
-
this.
|
|
14
|
-
this.count = 0
|
|
13
|
+
this.retryCount = 0
|
|
15
14
|
this.retryPromise = null
|
|
16
15
|
|
|
17
16
|
this.handler.onConnect((reason) => {
|
|
@@ -47,7 +46,8 @@ class Handler {
|
|
|
47
46
|
|
|
48
47
|
const err = createError(statusCode, { headers: parseHeaders(rawHeaders) })
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
// TODO (fix): abort signal?
|
|
50
|
+
const retryPromise = retryFn(err, this.retryCount++, this.opts)
|
|
51
51
|
if (retryPromise == null) {
|
|
52
52
|
return this.handler.onHeaders(statusCode, rawHeaders, resume, statusMessage)
|
|
53
53
|
}
|
|
@@ -70,26 +70,24 @@ class Handler {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
onError(err) {
|
|
73
|
-
if (this.timeout) {
|
|
74
|
-
clearTimeout(this.timeout)
|
|
75
|
-
this.timeout = null
|
|
76
|
-
}
|
|
77
|
-
|
|
78
73
|
if (this.retryPromise == null || this.aborted || isDisturbed(this.opts.body)) {
|
|
79
74
|
return this.handler.onError(err)
|
|
80
75
|
}
|
|
81
76
|
|
|
82
77
|
this.retryPromise
|
|
83
78
|
.then(() => {
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
if (!this.aborted) {
|
|
80
|
+
try {
|
|
81
|
+
this.dispatch(this.opts, this)
|
|
82
|
+
} catch (err2) {
|
|
83
|
+
this.handler.onError(new AggregateError([err, err2]))
|
|
84
|
+
}
|
|
89
85
|
}
|
|
90
86
|
})
|
|
91
87
|
.catch((err) => {
|
|
92
|
-
this.
|
|
88
|
+
if (!this.aborted) {
|
|
89
|
+
this.handler.onError(err)
|
|
90
|
+
}
|
|
93
91
|
})
|
|
94
92
|
this.retryPromise = null
|
|
95
93
|
|