fix: Correct comparison for typeof check. #308
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
*** I cannot validate tests execute due to following error during npm install:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@launchdarkly%2fprivate-js-mocks - Not found
npm ERR! 404
npm ERR! 404 '@launchdarkly/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'sdk-server'
Describe the solution you've provided
This fixes the following error on Node.js v14:
ReferenceError: performance is not defined
at Migration.trackLatency (//node_modules/@launchdarkly/js-server-sdk-common/dist/Migration.js:245:13)
Since
"undefined" !== undefined
😛Additional context
The
performance
module is available in Node 14, however, it is not available globally until Node 16. An ideal fix may be to include an import ofperformance
fromperf_hooks
- see https://stackoverflow.com/questions/46436943/referenceerror-performance-is-not-defined-when-using-performance-nowI originally wanted to add this in, but would be unable to validate that change due to npm install errors around a private package described above. Regardless, this fix appears to work using the existing fallback mechanism using Date objects.