-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fallback resource timing in web workers #6721
Conversation
c654f50
to
be008e2
Compare
Please let me know if you'd like to see benchmarks here -- I haven't bothered running them yet given how slight this change is. |
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.
Can you DRY up the repeated code here / extract it to util/performance.js
somehow?
.flowconfig
Outdated
@@ -8,6 +8,7 @@ | |||
.*/node_modules/htmltojsx/.* | |||
.*/node_modules/documentation/.* | |||
.*/node_modules/module-deps/.* | |||
.*/node_modules/bcryptjs/src/bower.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.
What's the rationale for this change? Doesn't look like bcryptjs is in the dependency tree.
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 ran into something similar to this the other day when I was using npm install
rather than yarn install
. I can't say for sure that's where this was introduced but I kept getting a test error in bcrypt until I removed node modules and reinstalled with yarn. This shouldn't be needed.
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's present in my node_modules after a fresh npm i
and causes flow test failures thanks to some templating wackiness. Not related to this PR and I'm happy to do whatever's most appropriate here. Replicated with node 6 and 8.
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.
Tom, if you remove this line from .flowconfig
then rm -rf node_modules
and reinstall with yarn install
does the bcrypt error go away?
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.
Ah, posted before refreshing to see @ryanhamley's comment. I see that yarn is the default here, if npm support isn't a consideration I'm happy to remove this change.
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 think npm install
should work the way you expected it to. We need to debug why it isn't, but that's a separate issue.
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.
npm install
doesn't use yarn.lock
, so it installs a newer version of @mapbox/batfish
, which pulls in bcryptjs via some transitive dependencies.
Let's revert here and consider using https://www.npmjs.com/package/use-yarn to avoid this gotcha in the future.
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.
@ryanhamley yes, confirmed that using yarn avoids the problem
@jfirebaugh sounds good, I've removed the relevant commit
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 opened a ticket for the npm bug #6774
2fea81b
to
ce293d6
Compare
Rebasing away the bower config commit did something weird to my last merge from master, prompting another merge and a strange-looking commit history in this PR. LMK if this is an issue and you need a fresh branch. |
e705671
to
179214d
Compare
This PR adds a fallback method to
collectResourceTiming: true
for browsers that don't implement theperformance.getEntries()
method properly in web workers. It provides as much data as can be collected now, and should return full data when these browsers correct their implementations.The availability of the
performance
API in web workers remains unpleasantly murky. Despite tickets like https://bugzilla.mozilla.org/show_bug.cgi?id=1425458 and badges declaring web worker availability bugs remain in major browsers. Specifically, it appears that in both Firefox and Safariperformance.getEntries
,performance.getEntriesByName
andperformance.getEntriesByType
return empty arrays in web workers regardless of whether the worker has made network requests.performance.mark
,performance.measure
and subsequent use ofperformance.getEntries*
do work, however. This is an inferior solution, asPerformanceMeasure
objects compare unfavorably toPerformanceResourceTiming
objects:Still, the basic timing data that can be collected is better than nothing.
This change does not alter any codepaths when
collectResourceTiming
is false. When it is true, a check on array length and an invocation ofperformance.mark()
are added to the status quo codepath. Obviously there's a bit more code for the fallback case, but it's pretty slight.Launch Checklist
document any changes to public APIsn/amanually test the debug pagetested on my instrumentile integration test page instead (GL JS debug page doesn't collect resource timing)