diff --git a/packages/server/lib/cloud/protocol.ts b/packages/server/lib/cloud/protocol.ts index 79acbbedee92..65b57855625c 100644 --- a/packages/server/lib/cloud/protocol.ts +++ b/packages/server/lib/cloud/protocol.ts @@ -25,7 +25,7 @@ const DELETE_DB = !process.env.CYPRESS_LOCAL_PROTOCOL_PATH // Timeout for upload const TWO_MINUTES = 120000 -const RETRY_DELAYS = [500, 1000, 2000, 4000, 8000, 16000, 32000] +const RETRY_DELAYS = [500, 1000] const DB_SIZE_LIMIT = 5000000000 const dbSizeLimit = () => { @@ -323,7 +323,17 @@ export class ProtocolManager implements ProtocolManagerShape { } } - const errorMessage = await res.json().catch(() => res.statusText) + const errorMessage = await res.json().catch(() => { + const url = new URL(uploadUrl) + + for (const [key, value] of url.searchParams) { + if (['x-amz-credential', 'x-amz-signature'].includes(key.toLowerCase())) { + url.searchParams.set(key, 'X'.repeat(value.length)) + } + } + + return `${res.status} ${res.statusText} (${url.href})` + }) debug(`error response: %O`, errorMessage) diff --git a/system-tests/__snapshots__/record_spec.js b/system-tests/__snapshots__/record_spec.js index a0889db322cc..20897f5b579e 100644 --- a/system-tests/__snapshots__/record_spec.js +++ b/system-tests/__snapshots__/record_spec.js @@ -3401,7 +3401,13 @@ exports['e2e record capture-protocol enabled protocol runtime errors non-fatal e ` -exports['capture-protocol api errors upload 500 - retries 8 times and fails continues 1'] = ` +exports['capture-protocol api errors fetch script 500 continues 1'] = ` +We encountered an unexpected error communicating with our servers. + +StatusCodeError: 500 - "500 - Internal Server Error" + +We will retry 1 more time in X second(s)... + ==================================================================================================== @@ -3457,14 +3463,13 @@ exports['capture-protocol api errors upload 500 - retries 8 times and fails cont - Video - Nothing to upload - Screenshot - 1 kB /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png - - Test Replay + - Test Replay - Failed Capturing - Error downloading capture code: 500 - "500 - Internal Server Error" Uploading Cloud Artifacts: . . . . . (Uploaded Cloud Artifacts) - - Screenshot - Done Uploading 1 kB in Xm, Ys ZZ.ZZms 1/2 /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png - - Test Replay - Failed Uploading after Xm, Ys ZZ.ZZms 2/2 - Internal Server Error + - Screenshot - Done Uploading 1 kB in Xm, Ys ZZ.ZZms 1/1 /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png ==================================================================================================== @@ -3485,7 +3490,7 @@ exports['capture-protocol api errors upload 500 - retries 8 times and fails cont ` -exports['capture-protocol api errors upload 500 - retries 7 times and succeeds on the last call continues 1'] = ` +exports['capture-protocol api errors error report 500 continues 1'] = ` ==================================================================================================== @@ -3569,13 +3574,7 @@ exports['capture-protocol api errors upload 500 - retries 7 times and succeeds o ` -exports['capture-protocol api errors fetch script 500 continues 1'] = ` -We encountered an unexpected error communicating with our servers. - -StatusCodeError: 500 - "500 - Internal Server Error" - -We will retry 1 more time in X second(s)... - +exports['e2e record capture-protocol enabled passing retrieves the capture protocol, uploads the db, and updates the artifact upload report 1'] = ` ==================================================================================================== @@ -3631,13 +3630,14 @@ We will retry 1 more time in X second(s)... - Video - Nothing to upload - Screenshot - 1 kB /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png - - Test Replay - Failed Capturing - Error downloading capture code: 500 - "500 - Internal Server Error" + - Test Replay - 1 kB Uploading Cloud Artifacts: . . . . . (Uploaded Cloud Artifacts) - - Screenshot - Done Uploading 1 kB in Xm, Ys ZZ.ZZms 1/1 /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png + - Screenshot - Done Uploading 1 kB in Xm, Ys ZZ.ZZms 1/2 /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png + - Test Replay - Done Uploading 1 kB in Xm, Ys ZZ.ZZms 2/2 ==================================================================================================== @@ -3658,7 +3658,7 @@ We will retry 1 more time in X second(s)... ` -exports['capture-protocol api errors error report 500 continues 1'] = ` +exports['capture-protocol api errors upload 500 - retries 3 times and fails continues 1'] = ` ==================================================================================================== @@ -3714,14 +3714,14 @@ exports['capture-protocol api errors error report 500 continues 1'] = ` - Video - Nothing to upload - Screenshot - 1 kB /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png - - Test Replay - 1 kB + - Test Replay Uploading Cloud Artifacts: . . . . . (Uploaded Cloud Artifacts) - Screenshot - Done Uploading 1 kB in Xm, Ys ZZ.ZZms 1/2 /XXX/XXX/XXX/cypress/screenshots/record_pass.cy.js/yay it passes.png - - Test Replay - Done Uploading 1 kB in Xm, Ys ZZ.ZZms 2/2 + - Test Replay - Failed Uploading after Xm, Ys ZZ.ZZms 2/2 - 500 Internal Server Error (http://localhost:1234/capture-protocol/upload/?x-amz-credential=XXXXXXXX&x-amz-signature=XXXXXXXXXXXXX) ==================================================================================================== @@ -3742,7 +3742,7 @@ exports['capture-protocol api errors error report 500 continues 1'] = ` ` -exports['e2e record capture-protocol enabled passing retrieves the capture protocol, uploads the db, and updates the artifact upload report 1'] = ` +exports['capture-protocol api errors upload 500 - retries 2 times and succeeds on the last call continues 1'] = ` ==================================================================================================== diff --git a/system-tests/lib/serverStub.ts b/system-tests/lib/serverStub.ts index f9d6c97c54a2..998656494a15 100644 --- a/system-tests/lib/serverStub.ts +++ b/system-tests/lib/serverStub.ts @@ -32,7 +32,7 @@ postInstanceTestsResponse.actions = [] export const postRunResponse = _.assign({}, postRunResponseWithWarnings, { warnings: [] }) // mocked here rather than attempting to intercept and mock an s3 req -export const CAPTURE_PROTOCOL_UPLOAD_URL = '/capture-protocol/upload/' +export const CAPTURE_PROTOCOL_UPLOAD_URL = '/capture-protocol/upload/?x-amz-credential=1234abcd&x-amz-signature=1a2b3c-4d5e6f' let protocolStub: { value: string diff --git a/system-tests/test/record_spec.js b/system-tests/test/record_spec.js index 0183635141ac..3938e1f3e5af 100644 --- a/system-tests/test/record_spec.js +++ b/system-tests/test/record_spec.js @@ -2307,7 +2307,7 @@ describe('e2e record', () => { snapshot: true, }).then((ret) => { const urls = getRequestUrls() - const artifactReport = getRequests().find(({ url }) => url === `PUT /instances/${instanceId}/artifacts`)?.body + const artifactReport = getRequests().find(({ url }) => url.includes(`/instances/${instanceId}/artifacts`))?.body expect(urls).to.include.members([`PUT ${CAPTURE_PROTOCOL_UPLOAD_URL}`]) @@ -2541,7 +2541,7 @@ describe('capture-protocol api errors', () => { })) } - describe('upload 500 - retries 8 times and fails', () => { + describe('upload 500 - retries 3 times and fails', () => { stubbedServerWithErrorOn('putCaptureProtocolUpload') it('continues', function () { process.env.API_RETRY_INTERVALS = '1000' @@ -2560,14 +2560,17 @@ describe('capture-protocol api errors', () => { const artifactReport = getRequests().find(({ url }) => url === `PUT /instances/${instanceId}/artifacts`)?.body expect(artifactReport?.protocol).to.exist() - expect(artifactReport?.protocol?.error).to.equal('Failed to upload after 8 attempts. Errors: Internal Server Error, Internal Server Error, Internal Server Error, Internal Server Error, Internal Server Error, Internal Server Error, Internal Server Error, Internal Server Error') + expect(artifactReport?.protocol?.error).to.equal( + 'Failed to upload after 3 attempts. Errors: 500 Internal Server Error (http://localhost:1234/capture-protocol/upload/?x-amz-credential=XXXXXXXX&x-amz-signature=XXXXXXXXXXXXX), 500 Internal Server Error (http://localhost:1234/capture-protocol/upload/?x-amz-credential=XXXXXXXX&x-amz-signature=XXXXXXXXXXXXX), 500 Internal Server Error (http://localhost:1234/capture-protocol/upload/?x-amz-credential=XXXXXXXX&x-amz-signature=XXXXXXXXXXXXX)', + ) + expect(artifactReport?.protocol?.errorStack).to.exist().and.not.to.be.empty() }) }) }) - describe('upload 500 - retries 7 times and succeeds on the last call', () => { - stubbedServerWithErrorOn('putCaptureProtocolUpload', 7) + describe('upload 500 - retries 2 times and succeeds on the last call', () => { + stubbedServerWithErrorOn('putCaptureProtocolUpload', 2) let archiveFile = ''