-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
refactor(StartUrl): switch from error to debugString object #2549
Changes from 1 commit
fbd724e
d3c8dfd
f98d4b9
6589cdd
1cf9b18
369058d
6cefcd6
5c9b84b
4a0e7d4
c552cab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,24 +49,29 @@ class StartUrl extends Gatherer { | |
pass(options) { | ||
return options.driver.getAppManifest() | ||
.then(response => { | ||
return manifestParser(response.data, response.url, options.url); | ||
return response && manifestParser(response.data, response.url, options.url); | ||
}) | ||
.then(manifest => { | ||
if (!manifest.value.start_url || !manifest.value.start_url.raw) { | ||
return Promise.reject(new Error(`No web app manifest found on page ${options.url}`)); | ||
if (!manifest || !manifest.value.start_url || !manifest.value.start_url.raw) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may have been the cause of this original conditional, but I don't think it's quite right.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
throw new Error(`No web app manifest found on page ${options.url}`); | ||
} | ||
|
||
if (manifest.value.start_url.debugString) { | ||
return Promise.reject(new Error(manifest.value.start_url.debugString)); | ||
throw new Error(manifest.value.start_url.debugString); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want this to be an error? It'll be things like Not sure if we want to fall on the "this is broken" side or the side of how the browser actually treats it since we don't have a great logging spot for that type of message if no error here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it wasn't it was being caught below |
||
} | ||
|
||
this.startUrl = manifest.value.start_url.value; | ||
}).then(_ => this.executeFetchRequest(options.driver, this.startUrl)); | ||
}) | ||
.then(_ => this.executeFetchRequest(options.driver, this.startUrl)) | ||
.catch(err => { | ||
this.debugString = err.message; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably better to set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that was kinda the point though since all of this could reasonably fail not because of a bug but just because of the page not having a service worker, fine with switching for now though and going back to this if it's too noisy |
||
}); | ||
} | ||
|
||
afterPass(options, tracingData) { | ||
if (!this.startUrl) { | ||
return Promise.reject(new Error('No start_url found inside the manifest')); | ||
if (this.debugString || !this.startUrl) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like either there's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not if manifestParser/getAppManifest fails, but I guess that's a different can of worms altogether There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yeah, in that case (if |
||
const debugString = this.debugString || 'No start_url found inside the manifest'; | ||
return Promise.resolve({debugString}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
} | ||
|
||
const networkRecords = tracingData.networkRecords; | ||
|
@@ -76,7 +81,9 @@ class StartUrl extends Gatherer { | |
}).pop(); // Take the last record that matches. | ||
|
||
return options.driver.goOnline(options) | ||
.then(_ => navigationRecord ? navigationRecord.statusCode : -1); | ||
.then(_ => { | ||
return {statusCode: navigationRecord ? navigationRecord.statusCode : -1}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
} | ||
} | ||
|
||
|
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.
🎉
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.
do you want to flatten the promise setup here while you're in here? Getting rid of the surrounding promise and then the resolve and rejects should be able to just be return/throw
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.
sure