forked from newrelic/node-newrelic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request newrelic#122 from michaelgoin/fix-version-checking
Fixes nr-hooks version checking circular reference issue.
- Loading branch information
Showing
2 changed files
with
91 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
|
||
const semver = require('semver') | ||
|
||
const ON_REQUIRE_COMPATIBLE_VERSIONS = '>=8.7.0' | ||
|
||
// TODO: Remove this semver check and semver module when we ship Node 18 support | ||
// A bug existed in 8.6.0 when we introduced the `onResolved` hook. | ||
// See: https://github.com/newrelic/node-newrelic/pull/986 | ||
// To avoid unnecessary support issues we will require agent version >= 8.7.0 to | ||
// register AWS SDK v3 instrumentation | ||
function checkAgentCompatible(agentVersion, logger, moduleName) { | ||
const isCompatible = semver.satisfies(agentVersion, ON_REQUIRE_COMPATIBLE_VERSIONS) | ||
|
||
if (!isCompatible) { | ||
logger.warn( | ||
`Agent version must be ${ON_REQUIRE_COMPATIBLE_VERSIONS} to instrument ${moduleName}. ` + | ||
`Current version: ${agentVersion}` | ||
) | ||
} | ||
|
||
return isCompatible | ||
} | ||
|
||
module.exports = checkAgentCompatible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters