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

fix: Add perfomance from perf_hooks (Node v8.5.0+) #251

Merged
merged 2 commits into from
Apr 20, 2020

Conversation

berezovskyicom
Copy link
Contributor

Fixes the error from 8.0.0-beta.20 regarding:

api: ReferenceError: performance is not defined
at makeRequest (project/node_modules/abstract-sdk/dist/endpoints/Endpoint.js:79:25)

@berezovskyicom
Copy link
Contributor Author

berezovskyicom commented Apr 14, 2020

Let's push 247 first and then merge this one

@berezovskyicom berezovskyicom self-assigned this Apr 14, 2020
@berezovskyicom berezovskyicom linked an issue Apr 14, 2020 that may be closed by this pull request
@@ -3,6 +3,8 @@
import { Readable } from "stream";
import "cross-fetch/polyfill";
import { spawn } from "child_process";
// $FlowFixMe
import { performance } from "perf_hooks";
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't ran this, but how does it handle running in the browser? It seems like you're swapping problems in one environment for another. I'd suggest creating a small wrapper and only requiring "perf_hooks" if you're not in a browser.

Copy link
Contributor

@tommoor tommoor left a comment

Choose a reason for hiding this comment

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

See question about browser compat

@rickharris
Copy link
Contributor

Looking back on this I think the mistake I made was putting the perf timings in the code unconditionally. I wish that I had put them inside the analytics callback check and checked for the existence of window.performance.now as well before calling it.

Since this isn't a documented feature, the only reason people are seeing this is because the calls to performance.now happen for everyone rather than just for folks who have configured the analyticsCallback.

@berezovskyicom berezovskyicom merged commit 6773642 into master Apr 20, 2020
@berezovskyicom berezovskyicom deleted the bugfix/perfomance-now branch April 20, 2020 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8.0.0-beta.20 throws error on performance
3 participants