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

AO-18716 fix node 14 non-existent property warning #139

Merged
merged 2 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/api-sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ let cls;
module.exports = function (appoptics) {
ao = appoptics;
aob = ao.addon;
cls = ao.cls;
// check for property to avoid triggering node 14 warning on
// non-existent property in unfinished module.exports
if (ao.hasOwnProperty('cls')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

a suggestion:
if ('cls' in ao) { seems to be the pattern used in this code base for testing properties
hasOwnProperty is a bit more restrictive, as it would return false for inherited properties
Less restrictive may be more future-proof

Copy link

Choose a reason for hiding this comment

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

I don't have any insight into which approach is preferable, but can confirm that the 'cls' in ao style also prevents the warning from appearing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know :). I did consider the property in object style checking but decided against it since these two properties are very specific to the agent and I didn't see a scenario where the agent would try inheriting them from some parent object.

cls = ao.cls;
}

// define the properties (some of which are part of the API)
definePropertiesOn(ao);
Expand Down Expand Up @@ -760,4 +764,3 @@ function insertLogObject (o = {}) {
function wrapLambdaHandler (fn) {
return fn;
}

4 changes: 3 additions & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ module.exports = function (appoptics) {
ao.maps.responseFinalizers = responseFinalizers;

// each invocation in lambda is counted
if (ao.lambda) {
// use property check that does not trigger node 14 warning on
// non-existent property in unfinished module.exports
if (ao.hasOwnProperty('lambda')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • dito -

ao.lambda.invocations = 0;
}

Expand Down