Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extension: another speculative fix for getCurrentTabURL; more logging #5323

Merged
merged 1 commit into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lighthouse-core/gather/connections/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,23 @@ class ExtensionConnection extends Connection {
if (chrome.runtime.lastError) {
return reject(chrome.runtime.lastError);
}

const errMessage = 'Couldn\'t resolve current tab. Check your URL, reload, and try again.';
if (tabs.length === 0) {
const message = 'Couldn\'t resolve current tab. Check your URL, reload, and try again.';
return reject(new Error(message));
return reject(new Error(errMessage));
}
if (tabs.length > 1) {
log.warn('ExtensionConnection', '_queryCurrentTab returned multiple tabs');
}
resolve(tabs[0]);

const firstUrledTab = tabs.find(tab => !!tab.url);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, firstUrledTab :)

if (!firstUrledTab) {
const tabIds = tabs.map(tab => tab.id).join(', ');
const message = errMessage + ` Found ${tabs.length} tab(s) with id(s) [${tabIds}].`;
return reject(new Error(message));
}

resolve(firstUrledTab);
}));
});
}
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Runner {
// save the requestedUrl provided by the user
const rawRequestedUrl = opts.url;
if (typeof rawRequestedUrl !== 'string' || rawRequestedUrl.length === 0) {
throw new Error('You must provide a url to the runner');
throw new Error(`You must provide a url to the runner. '${rawRequestedUrl}' provided.`);
}

let parsedURL;
Expand Down