Skip to content

Commit

Permalink
condensed down to 4 error cases, updated snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mann committed Feb 24, 2023
1 parent 245400f commit 5d38807
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 46 deletions.
4 changes: 4 additions & 0 deletions packages/server/lib/cloud/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ const tagError = function (err) {
// retry on timeouts, 5xx errors, or any error without a status code
// including decryption errors
const isRetriableError = (err) => {
if (err instanceof DecryptionError) {
return false
}

return err instanceof Bluebird.TimeoutError ||
(err.statusCode >= 500 && err.statusCode < 600) ||
(err.statusCode == null)
Expand Down
16 changes: 5 additions & 11 deletions system-tests/__snapshots__/record_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ https://on.cypress.io/cloud
`

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

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

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

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

exports['e2e record api interaction errors sendPreflight [F4] fails on 422 status codes even when encryption is off 1'] = `
We encountered an unexpected error communicating with our servers.
DecryptionError: JWE Recipients missing or incorrect type
We will retry 1 more time in X second(s)...
exports['e2e record api interaction errors sendPreflight [F3] 422 status code with invalid decryption fails without retrying 1'] = `
We encountered an unexpected error communicating with our servers.
DecryptionError: JWE Recipients missing or incorrect type
Expand Down
70 changes: 35 additions & 35 deletions system-tests/test/record_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ describe('e2e record', () => {
},
}))

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

return systemTests.exec(this, {
Expand All @@ -1642,7 +1642,7 @@ describe('e2e record', () => {
})
})

describe('[F1] status code errors with empty body', () => {
describe('[F1] 500 status code errors with empty body', () => {
setupStubbedServer(createRoutes({
sendPreflight: {
res (req, res) {
Expand All @@ -1651,7 +1651,7 @@ describe('e2e record', () => {
},
}))

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

return systemTests.exec(this, {
Expand All @@ -1669,7 +1669,7 @@ describe('e2e record', () => {
})
})

describe('[F1] status code errors with body', () => {
describe('[F1] 500 status code errors with body', () => {
setupStubbedServer(createRoutes({
sendPreflight: {
res (req, res) {
Expand All @@ -1680,7 +1680,7 @@ describe('e2e record', () => {
},
}))

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

return systemTests.exec(this, {
Expand All @@ -1698,7 +1698,7 @@ describe('e2e record', () => {
})
})

describe('[F2]', () => {
describe('[F2] 404 status code with JSON body', () => {
setupStubbedServer(createRoutes({
sendPreflight: {
res (req, res) {
Expand All @@ -1709,7 +1709,7 @@ describe('e2e record', () => {
},
}))

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

return systemTests.exec(this, {
Expand All @@ -1727,7 +1727,7 @@ describe('e2e record', () => {
})
})

describe('[F2]', () => {
describe('[F2] 404 status code with empty body', () => {
setupStubbedServer(createRoutes({
sendPreflight: {
res (req, res) {
Expand All @@ -1736,7 +1736,7 @@ describe('e2e record', () => {
},
}))

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

return systemTests.exec(this, {
Expand All @@ -1754,24 +1754,18 @@ describe('e2e record', () => {
})
})

describe('[F3]', () => {
describe('[F3] 422 status code with invalid decryption', () => {
setupStubbedServer(createRoutes({
sendPreflight: {
res: async (req, res) => {
return res.status(412).json(await encryptBody(req, res, {
message: 'Recording is not working',
errors: [
'attempted to send invalid data',
],
object: {
projectId: 'cy12345',
},
}))
return res.status(422).json({
message: 'something broke',
})
},
},
}))

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

return systemTests.exec(this, {
Expand All @@ -1789,18 +1783,18 @@ describe('e2e record', () => {
})
})

describe('[F4]', () => {
describe('[F3] 201 status code with invalid decryption', () => {
setupStubbedServer(createRoutes({
sendPreflight: {
res: async (req, res) => {
return res.status(422).json({
message: 'something broke',
})
res (req, res) {
return res
.status(201)
.json({ data: 'very encrypted and secure string' })
},
},
}))

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

return systemTests.exec(this, {
Expand All @@ -1818,18 +1812,16 @@ describe('e2e record', () => {
})
})

describe('[F5]', () => {
describe('[F3] 200 status code with empty body', () => {
setupStubbedServer(createRoutes({
sendPreflight: {
res (req, res) {
return res
.status(201)
.json({ data: 'very encrypted and secure string' })
return res.sendStatus(200)
},
},
}))

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

return systemTests.exec(this, {
Expand All @@ -1847,16 +1839,24 @@ describe('e2e record', () => {
})
})

describe('[F6]', () => {
describe('[F4] 412 status code with valid decryption', () => {
setupStubbedServer(createRoutes({
sendPreflight: {
res (req, res) {
return res.sendStatus(200)
res: async (req, res) => {
return res.status(412).json(await encryptBody(req, res, {
message: 'Recording is not working',
errors: [
'attempted to send invalid data',
],
object: {
projectId: 'cy12345',
},
}))
},
},
}))

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

return systemTests.exec(this, {
Expand Down

3 comments on commit 5d38807

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 5d38807 Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/linux-arm64/fix/preflight-5d3880772c4698daeae3fbb6ded27d6dc843b21c/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 5d38807 Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/linux-x64/fix/preflight-5d3880772c4698daeae3fbb6ded27d6dc843b21c/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 5d38807 Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.7.0/darwin-x64/fix/preflight-5d3880772c4698daeae3fbb6ded27d6dc843b21c/cypress.tgz

Please sign in to comment.