Skip to content

Commit 5d38807

Browse files
committed
condensed down to 4 error cases, updated snapshots
1 parent 245400f commit 5d38807

File tree

3 files changed

+44
-46
lines changed

3 files changed

+44
-46
lines changed

packages/server/lib/cloud/api.ts

+4
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ const tagError = function (err) {
217217
// retry on timeouts, 5xx errors, or any error without a status code
218218
// including decryption errors
219219
const isRetriableError = (err) => {
220+
if (err instanceof DecryptionError) {
221+
return false
222+
}
223+
220224
return err instanceof Bluebird.TimeoutError ||
221225
(err.statusCode >= 500 && err.statusCode < 600) ||
222226
(err.statusCode == null)

system-tests/__snapshots__/record_spec.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ https://on.cypress.io/cloud
25772577
25782578
`
25792579

2580-
exports['e2e record api interaction errors sendPreflight [F2] 404 status codes with empty body fails without retrying 1'] = `
2580+
exports['e2e record api interaction errors sendPreflight [F2] 404 status code with empty body fails without retrying 1'] = `
25812581
We could not find a Cypress Cloud project with the projectId: pid123
25822582
25832583
This projectId came from your cypress-with-project-id.config.js file or an environment variable.
@@ -2592,7 +2592,7 @@ https://on.cypress.io/cloud
25922592
25932593
`
25942594

2595-
exports['e2e record api interaction errors sendPreflight [F5] fails on OK status codes with invalid unencrypted data without retrying 1'] = `
2595+
exports['e2e record api interaction errors sendPreflight [F3] 201 status code with invalid decryption fails without retrying 1'] = `
25962596
We encountered an unexpected error communicating with our servers.
25972597
25982598
DecryptionError: JWE Recipients missing or incorrect type
@@ -2604,7 +2604,7 @@ The --ciBuildId flag you passed was: ciBuildId123
26042604
26052605
`
26062606

2607-
exports['e2e record api interaction errors sendPreflight [F6] fails on OK status codes with empty body without retrying 1'] = `
2607+
exports['e2e record api interaction errors sendPreflight [F3] 200 status code with empty body fails without retrying 1'] = `
26082608
We encountered an unexpected error communicating with our servers.
26092609
26102610
DecryptionError: General JWE must be an object
@@ -2616,7 +2616,7 @@ The --ciBuildId flag you passed was: ciBuildId123
26162616
26172617
`
26182618

2619-
exports['e2e record api interaction errors sendPreflight [F3] fails on 412 status codes when request is invalid 1'] = `
2619+
exports['e2e record api interaction errors sendPreflight [F4] 412 status code with valid decryption fails without retrying 1'] = `
26202620
Recording this run failed. The request was invalid.
26212621
26222622
Recording is not working
@@ -2739,13 +2739,7 @@ The --ciBuildId flag you passed was: ciBuildId123
27392739
27402740
`
27412741

2742-
exports['e2e record api interaction errors sendPreflight [F4] fails on 422 status codes even when encryption is off 1'] = `
2743-
We encountered an unexpected error communicating with our servers.
2744-
2745-
DecryptionError: JWE Recipients missing or incorrect type
2746-
2747-
We will retry 1 more time in X second(s)...
2748-
2742+
exports['e2e record api interaction errors sendPreflight [F3] 422 status code with invalid decryption fails without retrying 1'] = `
27492743
We encountered an unexpected error communicating with our servers.
27502744
27512745
DecryptionError: JWE Recipients missing or incorrect type

system-tests/test/record_spec.js

+35-35
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ describe('e2e record', () => {
16241624
},
16251625
}))
16261626

1627-
it('fails on request socket errors after retrying', function () {
1627+
it('fails after retrying', function () {
16281628
process.env.API_RETRY_INTERVALS = '1000'
16291629

16301630
return systemTests.exec(this, {
@@ -1642,7 +1642,7 @@ describe('e2e record', () => {
16421642
})
16431643
})
16441644

1645-
describe('[F1] status code errors with empty body', () => {
1645+
describe('[F1] 500 status code errors with empty body', () => {
16461646
setupStubbedServer(createRoutes({
16471647
sendPreflight: {
16481648
res (req, res) {
@@ -1651,7 +1651,7 @@ describe('e2e record', () => {
16511651
},
16521652
}))
16531653

1654-
it('fails on 500 status codes after retrying', function () {
1654+
it('fails after retrying', function () {
16551655
process.env.API_RETRY_INTERVALS = '1000'
16561656

16571657
return systemTests.exec(this, {
@@ -1669,7 +1669,7 @@ describe('e2e record', () => {
16691669
})
16701670
})
16711671

1672-
describe('[F1] status code errors with body', () => {
1672+
describe('[F1] 500 status code errors with body', () => {
16731673
setupStubbedServer(createRoutes({
16741674
sendPreflight: {
16751675
res (req, res) {
@@ -1680,7 +1680,7 @@ describe('e2e record', () => {
16801680
},
16811681
}))
16821682

1683-
it('fails on 500 status codes after retrying', function () {
1683+
it('fails after retrying', function () {
16841684
process.env.API_RETRY_INTERVALS = '1000'
16851685

16861686
return systemTests.exec(this, {
@@ -1698,7 +1698,7 @@ describe('e2e record', () => {
16981698
})
16991699
})
17001700

1701-
describe('[F2]', () => {
1701+
describe('[F2] 404 status code with JSON body', () => {
17021702
setupStubbedServer(createRoutes({
17031703
sendPreflight: {
17041704
res (req, res) {
@@ -1709,7 +1709,7 @@ describe('e2e record', () => {
17091709
},
17101710
}))
17111711

1712-
it('fails on 404 status codes with JSON body without retrying', function () {
1712+
it('fails without retrying', function () {
17131713
process.env.API_RETRY_INTERVALS = '1000'
17141714

17151715
return systemTests.exec(this, {
@@ -1727,7 +1727,7 @@ describe('e2e record', () => {
17271727
})
17281728
})
17291729

1730-
describe('[F2]', () => {
1730+
describe('[F2] 404 status code with empty body', () => {
17311731
setupStubbedServer(createRoutes({
17321732
sendPreflight: {
17331733
res (req, res) {
@@ -1736,7 +1736,7 @@ describe('e2e record', () => {
17361736
},
17371737
}))
17381738

1739-
it('fails on 404 status codes without JSON body without retrying', function () {
1739+
it('fails without retrying', function () {
17401740
process.env.API_RETRY_INTERVALS = '1000'
17411741

17421742
return systemTests.exec(this, {
@@ -1754,24 +1754,18 @@ describe('e2e record', () => {
17541754
})
17551755
})
17561756

1757-
describe('[F3]', () => {
1757+
describe('[F3] 422 status code with invalid decryption', () => {
17581758
setupStubbedServer(createRoutes({
17591759
sendPreflight: {
17601760
res: async (req, res) => {
1761-
return res.status(412).json(await encryptBody(req, res, {
1762-
message: 'Recording is not working',
1763-
errors: [
1764-
'attempted to send invalid data',
1765-
],
1766-
object: {
1767-
projectId: 'cy12345',
1768-
},
1769-
}))
1761+
return res.status(422).json({
1762+
message: 'something broke',
1763+
})
17701764
},
17711765
},
17721766
}))
17731767

1774-
it('fails on 412 status codes when request is invalid', function () {
1768+
it('fails without retrying', function () {
17751769
process.env.API_RETRY_INTERVALS = '1000'
17761770

17771771
return systemTests.exec(this, {
@@ -1789,18 +1783,18 @@ describe('e2e record', () => {
17891783
})
17901784
})
17911785

1792-
describe('[F4]', () => {
1786+
describe('[F3] 201 status code with invalid decryption', () => {
17931787
setupStubbedServer(createRoutes({
17941788
sendPreflight: {
1795-
res: async (req, res) => {
1796-
return res.status(422).json({
1797-
message: 'something broke',
1798-
})
1789+
res (req, res) {
1790+
return res
1791+
.status(201)
1792+
.json({ data: 'very encrypted and secure string' })
17991793
},
18001794
},
18011795
}))
18021796

1803-
it('fails on 422 status codes even when encryption is off', function () {
1797+
it('fails without retrying', function () {
18041798
process.env.API_RETRY_INTERVALS = '1000'
18051799

18061800
return systemTests.exec(this, {
@@ -1818,18 +1812,16 @@ describe('e2e record', () => {
18181812
})
18191813
})
18201814

1821-
describe('[F5]', () => {
1815+
describe('[F3] 200 status code with empty body', () => {
18221816
setupStubbedServer(createRoutes({
18231817
sendPreflight: {
18241818
res (req, res) {
1825-
return res
1826-
.status(201)
1827-
.json({ data: 'very encrypted and secure string' })
1819+
return res.sendStatus(200)
18281820
},
18291821
},
18301822
}))
18311823

1832-
it('fails on OK status codes with invalid unencrypted data without retrying', function () {
1824+
it('fails without retrying', function () {
18331825
process.env.API_RETRY_INTERVALS = '1000'
18341826

18351827
return systemTests.exec(this, {
@@ -1847,16 +1839,24 @@ describe('e2e record', () => {
18471839
})
18481840
})
18491841

1850-
describe('[F6]', () => {
1842+
describe('[F4] 412 status code with valid decryption', () => {
18511843
setupStubbedServer(createRoutes({
18521844
sendPreflight: {
1853-
res (req, res) {
1854-
return res.sendStatus(200)
1845+
res: async (req, res) => {
1846+
return res.status(412).json(await encryptBody(req, res, {
1847+
message: 'Recording is not working',
1848+
errors: [
1849+
'attempted to send invalid data',
1850+
],
1851+
object: {
1852+
projectId: 'cy12345',
1853+
},
1854+
}))
18551855
},
18561856
},
18571857
}))
18581858

1859-
it('fails on OK status codes with empty body without retrying', function () {
1859+
it('fails without retrying', function () {
18601860
process.env.API_RETRY_INTERVALS = '1000'
18611861

18621862
return systemTests.exec(this, {

0 commit comments

Comments
 (0)