fix(tracing): do not serialise out-of-process Buffers (#29425)
This commit is contained in:
parent
b15a7076dc
commit
498b8bb269
|
|
@ -351,7 +351,7 @@ export class DispatcherConnection {
|
||||||
const result = await dispatcher._handleCommand(callMetadata, method, validParams);
|
const result = await dispatcher._handleCommand(callMetadata, method, validParams);
|
||||||
const validator = findValidator(dispatcher._type, method, 'Result');
|
const validator = findValidator(dispatcher._type, method, 'Result');
|
||||||
response.result = validator(result, '', { tChannelImpl: this._tChannelImplToWire.bind(this), binary: this._isLocal ? 'buffer' : 'toBase64' });
|
response.result = validator(result, '', { tChannelImpl: this._tChannelImplToWire.bind(this), binary: this._isLocal ? 'buffer' : 'toBase64' });
|
||||||
callMetadata.result = response.result;
|
callMetadata.result = result;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (isTargetClosedError(e) && sdkObject) {
|
if (isTargetClosedError(e) && sdkObject) {
|
||||||
const reason = closeReason(sdkObject);
|
const reason = closeReason(sdkObject);
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,5 @@
|
||||||
../../../utils/
|
../../../utils/
|
||||||
../../../utilsBundle.ts
|
../../../utilsBundle.ts
|
||||||
../../../zipBundle.ts
|
../../../zipBundle.ts
|
||||||
../common/
|
../../dispatchers/dispatcher.ts
|
||||||
|
../common/
|
||||||
|
|
@ -42,6 +42,7 @@ import type { SnapshotterBlob, SnapshotterDelegate } from './snapshotter';
|
||||||
import { Snapshotter } from './snapshotter';
|
import { Snapshotter } from './snapshotter';
|
||||||
import { yazl } from '../../../zipBundle';
|
import { yazl } from '../../../zipBundle';
|
||||||
import type { ConsoleMessage } from '../../console';
|
import type { ConsoleMessage } from '../../console';
|
||||||
|
import { Dispatcher } from '../../dispatchers/dispatcher';
|
||||||
|
|
||||||
const version: trace.VERSION = 6;
|
const version: trace.VERSION = 6;
|
||||||
|
|
||||||
|
|
@ -496,8 +497,10 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
|
||||||
function visitTraceEvent(object: any, sha1s: Set<string>): any {
|
function visitTraceEvent(object: any, sha1s: Set<string>): any {
|
||||||
if (Array.isArray(object))
|
if (Array.isArray(object))
|
||||||
return object.map(o => visitTraceEvent(o, sha1s));
|
return object.map(o => visitTraceEvent(o, sha1s));
|
||||||
|
if (object instanceof Dispatcher)
|
||||||
|
return `<${(object as Dispatcher<any, any, any>)._type}>`;
|
||||||
if (object instanceof Buffer)
|
if (object instanceof Buffer)
|
||||||
return undefined;
|
return `<Buffer>`;
|
||||||
if (object instanceof Date)
|
if (object instanceof Date)
|
||||||
return object;
|
return object;
|
||||||
if (typeof object === 'object') {
|
if (typeof object === 'object') {
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,7 @@ test('should not collect snapshots by default', async ({ context, page, server }
|
||||||
expect(events.some(e => e.type === 'resource-snapshot')).toBeFalsy();
|
expect(events.some(e => e.type === 'resource-snapshot')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not include buffers in the trace', async ({ context, page, server, mode }, testInfo) => {
|
test('should not include buffers in the trace', async ({ context, page, server }, testInfo) => {
|
||||||
test.skip(mode !== 'default', 'no buffers with remote connections');
|
|
||||||
|
|
||||||
await context.tracing.start({ snapshots: true });
|
await context.tracing.start({ snapshots: true });
|
||||||
await page.goto(server.PREFIX + '/empty.html');
|
await page.goto(server.PREFIX + '/empty.html');
|
||||||
await page.screenshot();
|
await page.screenshot();
|
||||||
|
|
@ -120,7 +118,9 @@ test('should not include buffers in the trace', async ({ context, page, server,
|
||||||
const screenshotEvent = actionObjects.find(a => a.apiName === 'page.screenshot');
|
const screenshotEvent = actionObjects.find(a => a.apiName === 'page.screenshot');
|
||||||
expect(screenshotEvent.beforeSnapshot).toBeTruthy();
|
expect(screenshotEvent.beforeSnapshot).toBeTruthy();
|
||||||
expect(screenshotEvent.afterSnapshot).toBeTruthy();
|
expect(screenshotEvent.afterSnapshot).toBeTruthy();
|
||||||
expect(screenshotEvent.result).toEqual({});
|
expect(screenshotEvent.result).toEqual({
|
||||||
|
'binary': '<Buffer>',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should exclude internal pages', async ({ browserName, context, page, server }, testInfo) => {
|
test('should exclude internal pages', async ({ browserName, context, page, server }, testInfo) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue