chore: do not try/catch buffer.concat (#1575)
This commit is contained in:
parent
e796bfd815
commit
4e89939ece
|
|
@ -223,14 +223,13 @@ export class CRBrowser extends platform.EventEmitter implements Browser {
|
|||
|
||||
async stopTracing(): Promise<platform.BufferType> {
|
||||
assert(this._tracingClient, 'Tracing was not started.');
|
||||
let fulfill: (buffer: platform.BufferType) => void;
|
||||
const contentPromise = new Promise<platform.BufferType>(x => fulfill = x);
|
||||
this._tracingClient.once('Tracing.tracingComplete', event => {
|
||||
readProtocolStream(this._tracingClient!, event.stream!, this._tracingPath).then(fulfill);
|
||||
});
|
||||
await this._tracingClient.send('Tracing.end');
|
||||
const [event] = await Promise.all([
|
||||
new Promise(f => this._tracingClient!.once('Tracing.tracingComplete', f)),
|
||||
this._tracingClient.send('Tracing.end')
|
||||
]);
|
||||
const result = await readProtocolStream(this._tracingClient, (event as any).stream!, this._tracingPath);
|
||||
this._tracingRecording = false;
|
||||
return contentPromise;
|
||||
return result;
|
||||
}
|
||||
|
||||
isConnected(): boolean {
|
||||
|
|
|
|||
|
|
@ -78,12 +78,7 @@ export async function readProtocolStream(client: CRSession, handle: string, path
|
|||
if (path)
|
||||
await platform.closeFdAsync(fd!);
|
||||
await client.send('IO.close', {handle});
|
||||
let resultBuffer = null;
|
||||
try {
|
||||
resultBuffer = platform.Buffer.concat(bufs);
|
||||
} finally {
|
||||
return resultBuffer!;
|
||||
}
|
||||
return platform.Buffer.concat(bufs);
|
||||
}
|
||||
|
||||
export function toConsoleMessageLocation(stackTrace: Protocol.Runtime.StackTrace | undefined) {
|
||||
|
|
|
|||
|
|
@ -75,17 +75,6 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, b
|
|||
const trace = await browser.stopTracing();
|
||||
expect(trace).toBeTruthy();
|
||||
});
|
||||
it('should return null in case of Buffer error', async({browser, page, server}) => {
|
||||
await browser.startTracing(page, {screenshots: true});
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
const oldBufferConcat = Buffer.concat;
|
||||
Buffer.concat = bufs => {
|
||||
throw new Error('Buffer.concat fake error, should be caught by playwright');
|
||||
};
|
||||
const trace = await browser.stopTracing();
|
||||
expect(trace).toEqual(null);
|
||||
Buffer.concat = oldBufferConcat;
|
||||
});
|
||||
it('should support a buffer without a path', async({browser, page, server}) => {
|
||||
await browser.startTracing(page, {screenshots: true});
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
|
|
|
|||
Loading…
Reference in a new issue