@@ -88,23 +88,20 @@ const rp = request.defaults((params: CypressRequestOptions, callback) => {
88
88
if ( params . encrypt === true || params . encrypt === 'always' ) {
89
89
const { secretKey, jwe } = await enc . encryptRequest ( params )
90
90
91
- // TODO: double check the logic below here with @tgriesser
92
91
params . transform = async function ( body , response ) {
93
92
const { statusCode } = response
94
93
95
94
// response is valid and we are encrypting
96
95
if ( response . headers [ 'x-cypress-encrypted' ] || params . encrypt === 'always' ) {
97
96
let decryptedBody
98
97
99
- // TODO: if body is null/undefined throw a custom error
100
-
101
98
try {
102
99
decryptedBody = await enc . decryptResponse ( body , secretKey )
103
100
} catch ( e ) {
104
101
// we failed decrypting the response...
105
102
106
103
// if status code is >=500 or 404 just return body
107
- if ( statusCode >= 500 || statusCode === 404 || statusCode === 422 ) {
104
+ if ( statusCode >= 500 || statusCode === 404 ) {
108
105
return body
109
106
}
110
107
@@ -113,7 +110,6 @@ const rp = request.defaults((params: CypressRequestOptions, callback) => {
113
110
114
111
// If we've hit an encrypted payload error case, we need to re-constitute the error
115
112
// as it would happen normally, with the body as an error property
116
- // TODO: need to look harder at this to better understand why its necessary
117
113
if ( response . statusCode > 400 ) {
118
114
throw new RequestErrors . StatusCodeError ( response . statusCode , decryptedBody , { } , decryptedBody )
119
115
}
@@ -184,8 +180,8 @@ const retryWithBackoff = (fn) => {
184
180
return attempt ( retryIndex )
185
181
} )
186
182
} )
187
- // TODO: look at this too
188
183
. catch ( RequestErrors . TransformError , ( err ) => {
184
+ // Unroll the error thrown from within the transform
189
185
throw err . cause
190
186
} )
191
187
}
@@ -258,7 +254,6 @@ module.exports = {
258
254
}
259
255
} ,
260
256
261
- // TODO: i think we can remove this function
262
257
resetPreflightResult ( ) {
263
258
recordRoutes = apiRoutes
264
259
preflightResult = {
0 commit comments