diff --git a/packages/server/lib/cloud/protocol.ts b/packages/server/lib/cloud/protocol.ts index 4669ec21be..cf41aabd72 100644 --- a/packages/server/lib/cloud/protocol.ts +++ b/packages/server/lib/cloud/protocol.ts @@ -168,6 +168,10 @@ export class ProtocolManager implements ProtocolManagerShape { } async beforeTest (test: { id: string } & Record) { + if (!test.id) { + debug('protocolManager beforeTest was invoked with test without id %O', test) + } + this._runnableId = test.id await this.invokeAsync('beforeTest', { isEssential: true }, test) } diff --git a/packages/server/lib/modes/record.js b/packages/server/lib/modes/record.js index 9d10987993..72100c7c1a 100644 --- a/packages/server/lib/modes/record.js +++ b/packages/server/lib/modes/record.js @@ -162,6 +162,11 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => { if (protocolManager.hasFatalError()) { const error = protocolManager.getFatalError().error + debug('protocol fatal error encountered', { + message: error.message, + stack: error.stack, + }) + return { ...artifact, skip: true, @@ -186,6 +191,7 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => { } } catch (err) { debug('failed to prepare protocol artifact', { + error: err.message, stack: err.stack, }) } @@ -223,7 +229,11 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => { } preparedArtifacts.forEach((artifact) => { - debug('preparing to upload artifact %O', artifact) + debug('preparing to upload artifact %O', { + ...artifact, + payload: typeof artifact.payload, + }) + if (!quiet) { printPendingArtifactUpload(artifact, labels) } @@ -237,11 +247,16 @@ const uploadArtifactBatch = async (artifacts, protocolManager, quiet) => { return { key: artifact.reportKey, skipped: true, + url: artifact.url || '', ...(artifact.error && { error: artifact.error, success: false }), } } - debug('uploading artifact %O', artifact) + debug('uploading artifact %O', { + ...artifact, + payload: typeof artifact.payload, + }) + try { if (artifact.reportKey === 'protocol') { const res = await protocolManager.uploadCaptureArtifact(artifact) diff --git a/system-tests/test/record_spec.js b/system-tests/test/record_spec.js index 2a42b6fa62..df5a0707bc 100644 --- a/system-tests/test/record_spec.js +++ b/system-tests/test/record_spec.js @@ -2332,7 +2332,14 @@ describe('e2e record', () => { }).then(() => { const urls = getRequestUrls() + expect(urls).to.include.members([`PUT /instances/${instanceId}/artifacts`]) expect(urls).not.to.include.members([`PUT ${CAPTURE_PROTOCOL_UPLOAD_URL}`]) + + const artifactReport = getRequests().find(({ url }) => url === `PUT /instances/${instanceId}/artifacts`)?.body + + expect(artifactReport?.protocol).to.exist() + expect(artifactReport?.protocol?.error).to.exist().and.not.to.be.empty() + expect(artifactReport?.protocol?.url).to.exist() }) }) }) @@ -2357,6 +2364,7 @@ describe('e2e record', () => { expect(artifactReport?.protocol).to.exist() expect(artifactReport?.protocol?.error).to.exist().and.not.to.be.empty() + expect(artifactReport?.protocol?.url).to.exist() }) }) }) @@ -2381,6 +2389,7 @@ describe('e2e record', () => { expect(artifactReport?.protocol).to.exist() expect(artifactReport?.protocol?.error).to.exist().and.not.to.be.empty() + expect(artifactReport?.protocol?.url).to.exist() }) }) })