diff --git a/packages/server/lib/cloud/protocol.ts b/packages/server/lib/cloud/protocol.ts index ed90cdd19e38..0f26cd6aea2a 100644 --- a/packages/server/lib/cloud/protocol.ts +++ b/packages/server/lib/cloud/protocol.ts @@ -8,6 +8,7 @@ import os from 'os' import { createGzip } from 'zlib' import fetch from 'cross-fetch' import { performance } from 'perf_hooks' +import crypto from 'crypto' const routes = require('./routes') const pkg = require('@packages/root') @@ -46,6 +47,9 @@ export class ProtocolManager implements ProtocolManagerShape { now: performance.now, timeOrigin: performance.timeOrigin, }, + createHash: (text) => { + return crypto.createHash('md5').update(text).digest('hex') + }, }, }) @@ -78,6 +82,7 @@ export class ProtocolManager implements ProtocolManagerShape { if (CAPTURE_ERRORS) { this._errors.push({ captureMethod: 'cdpClient.on', error, args: [event, message] }) } else { + debug('error in cdpClient.on %O', { error, event, message }) throw error } } diff --git a/packages/server/test/support/fixtures/cloud/protocol/test-protocol.ts b/packages/server/test/support/fixtures/cloud/protocol/test-protocol.ts index e6410abf08bf..9512dadc8245 100644 --- a/packages/server/test/support/fixtures/cloud/protocol/test-protocol.ts +++ b/packages/server/test/support/fixtures/cloud/protocol/test-protocol.ts @@ -5,14 +5,19 @@ declare const performance: { now(): number timeOrigin: number } +declare const createHash: { + (text: string): string +} export class AppCaptureProtocol implements ProtocolManagerShape { private Debug: typeof Debug private performance: typeof performance + private createHash: typeof createHash constructor () { this.Debug = Debug this.performance = performance + this.createHash = createHash } setupProtocol = (script, runId) => { diff --git a/packages/server/test/unit/cloud/protocol_spec.ts b/packages/server/test/unit/cloud/protocol_spec.ts index b67c286395c5..bb29aa090933 100644 --- a/packages/server/test/unit/cloud/protocol_spec.ts +++ b/packages/server/test/unit/cloud/protocol_spec.ts @@ -42,6 +42,7 @@ describe('lib/cloud/protocol', () => { expect((protocol as any).performance).not.to.be.undefined expect((protocol as any).performance.now).not.to.be.undefined expect((protocol as any).performance.timeOrigin).not.to.be.undefined + expect((protocol as any).createHash).not.to.be.undefined }) it('should be able to connect to the browser', async () => { diff --git a/system-tests/lib/protocolStub.ts b/system-tests/lib/protocolStub.ts index 736faf84abef..6803bcad0acd 100644 --- a/system-tests/lib/protocolStub.ts +++ b/system-tests/lib/protocolStub.ts @@ -5,14 +5,19 @@ declare const performance: { now(): number timeOrigin: number } +declare const createHash: { + (text: string): string +} export class AppCaptureProtocol implements ProtocolManagerShape { private Debug: typeof Debug private performance: typeof performance + private createHash: typeof createHash constructor () { this.Debug = Debug this.performance = performance + this.createHash = createHash } setupProtocol = (script, runId) => {