-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Reject when main request fails #1174
Conversation
@@ -203,6 +203,10 @@ class GatherRunner { | |||
log.log('status', status); | |||
return driver.endNetworkCollect(); | |||
}).then(networkRecords => { | |||
if (driver.online && networkRecords[0].failed) { | |||
log.error('statusEnd', networkRecords[0].localizedFailDescription); | |||
return Promise.reject(new Error(networkRecords[0].localizedFailDescription)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something more friendly for the message?
`${options.url} could not be resolved`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The request could've failed for other reasons than 'not resolved'. Maybe my PR title is a bit too specific.
online: false, | ||
endNetworkCollect() { | ||
return Promise.resolve( | ||
recordsFromLogs(require('./fixtures/unresolved-perflog.json')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might as well require this once, at the top of the file.
.then(_ => { | ||
assert.ok(false); | ||
}, error => { | ||
assert.ok(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check doesn't do much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean? The result throws when run
resolves and resolves when run
throws. What do you suggest instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just meant that you're checking if you get here, the promise rejects. But there's another assert.equal
that falls under this rejection too. I think it's fine too keep as you have. Doesn't hurt.
return Runner.run({}, {url, config, driverMock: unresolvedDriver}) | ||
.then(_ => { | ||
assert.ok(true); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably should have a reject case here with assert.ok(false);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Mocha handles rejected promises just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with 151-153 and make sure your code isn't throwing.
Nice change. I've been bitten by a faulty url a couple of times when LH tests the offline page in Chrome :) Is there a way to exit cleanly in this case without causing a runtime error? Similar to what LH does when you do not provide a URL. Although catching the error is better than we had before, this is fairly unfriendly: |
@ebidel use |
This works for me. |
Leaving it open for anyone else to add comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good.
This error will also need to be handled in the extension here so we don't get a bunch of issues filed for testing non existent pages :)
@@ -126,6 +128,61 @@ describe('Runner', () => { | |||
}); | |||
}); | |||
|
|||
it('rejects when domain name can\'t be resolved', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if these could be narrowed in scope by adding them to gather-runner-test.js
instead and cutting out Runner
from the tests
@@ -241,8 +242,15 @@ function showProtocolTimeoutError() { | |||
process.exit(_PROTOCOL_TIMEOUT_EXIT_CODE); | |||
} | |||
|
|||
function showPageLoadError() { | |||
console.error('Unable to load the page.'); | |||
process.exit(_PAGE_LOAD_ERROR_EXIT_CODE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting. Any reason to have a special error code (vs using _RUNTIME_ERROR_CODE
)? No big deal if so, we added _PROTOCOL_TIMEOUT_EXIT_CODE
specifically because we needed to detect that case for Travis retries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, no reason. Just trying to match the style of the surrounding code. Will change to _RUNTIME_ERROR_CODE
@@ -241,8 +242,15 @@ function showProtocolTimeoutError() { | |||
process.exit(_PROTOCOL_TIMEOUT_EXIT_CODE); | |||
} | |||
|
|||
function showPageLoadError() { | |||
console.error('Unable to load the page.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add something friendly here about rechecking the URL and that the page is actually working?
@@ -203,6 +203,12 @@ class GatherRunner { | |||
log.log('status', status); | |||
return driver.endNetworkCollect(); | |||
}).then(networkRecords => { | |||
if (driver.online && networkRecords[0].failed) { | |||
log.error('statusEnd', networkRecords[0].localizedFailDescription); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.error('GatherRunner', networkRecords[0].localizedFailDescription);
@brendankenny Can you take another look? |
@Janpot can you look into the failing tests? |
@ebidel Ok, so I can't reproduce this locally but here's what's happening on travis for some reason: It fails on apparently In the meantime I will fix the logic by selecting the correct resource with the url. Will have to refactor a few things as there's a lot of mocking in the tests that breaks when I add my solution. Will continue on this when I have time again. |
@@ -172,6 +172,11 @@ document.addEventListener('DOMContentLoaded', _ => { | |||
} | |||
} | |||
|
|||
if (err.code === 'PAGE_LOAD_ERROR') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry to add one last thing, but it would be great to fold this into the known error messages handling above. Error matching is on message
string, not code
, but since it appears we never actually expose the message directly, it would be easy to prefix mainRecord.localizedFailDescription
with some string ('Unable to load the page: '
or whatever), then use that as the key in NON_BUG_ERROR_MESSAGES
nice catch on network record ordering. Beyond the DBW smoke test CSP issue, it's nice to have the more robust search for the root network record in this PR |
Another thing I noticed (but wasn't really an issue) was that chrome on Travis is out of date. Might want to clear the cache there once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☁️ ➡️ ✂️ ➡️ 💻 🚫
LGTM!
@brendankenny Your emoji's... Does it mean you're manually squashing and merging to master? If so, I'll make sure to squash and rebase in the future to save you the hassle (I usually use the GitHub squash+rebase) |
no, squashed via github UI
Obviously this is a pictographic representation of displaying an error when the computer's connection to the test page (in the cloud) is severed :P |
Tests might need some reordering