Skip to content

Commit

Permalink
core(connection): drop /new tab creation fallback (#14012)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish authored Jun 10, 2022
1 parent e3c0e21 commit cec61a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
20 changes: 3 additions & 17 deletions lighthouse-core/gather/connections/cri.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,9 @@ class CriConnection extends Connection {
* @override
* @return {Promise<void>}
*/
connect() {
return this._runJsonCommand('new')
.then(response => this._connectToSocket(/** @type {LH.DevToolsJsonTarget} */(response)))
.catch(_ => {
// COMPAT: headless didn't support `/json/new` before m59. (#970, crbug.com/699392)
// If no support, we fallback and reuse an existing open tab
log.warn('CriConnection', 'Cannot create new tab; reusing open tab.');
return this._runJsonCommand('list').then(tabs => {
if (!Array.isArray(tabs) || tabs.length === 0) {
return Promise.reject(new Error('Cannot create new tab, and no tabs already open.'));
}
const firstTab = tabs[0];
// first, we activate it to a foreground tab, then we connect
return this._runJsonCommand(`activate/${firstTab.id}`)
.then(() => this._connectToSocket(firstTab));
});
});
async connect() {
const response = await this._runJsonCommand('new');
return this._connectToSocket(/** @type {LH.DevToolsJsonTarget} */(response));
}

/**
Expand Down
7 changes: 3 additions & 4 deletions lighthouse-core/lib/asset-saver.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,9 @@ async function saveAssets(artifacts, audits, pathWithBasename) {
fs.writeFileSync(devtoolsLogFilename, JSON.stringify(passAssets.devtoolsLog, null, 2));
log.log('saveAssets', 'devtools log saved to disk: ' + devtoolsLogFilename);

const streamTraceFilename = `${pathWithBasename}-${index}${traceSuffix}`;
log.log('saveAssets', 'streaming trace file to disk: ' + streamTraceFilename);
await saveTrace(passAssets.traceData, streamTraceFilename);
log.log('saveAssets', 'trace file streamed to disk: ' + streamTraceFilename);
const traceFilename = `${pathWithBasename}-${index}${traceSuffix}`;
await saveTrace(passAssets.traceData, traceFilename);
log.log('saveAssets', 'trace file streamed to disk: ' + traceFilename);
});

await Promise.all(saveAll);
Expand Down

0 comments on commit cec61a0

Please sign in to comment.