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

entire CDK: NPM bundle includes semantically incorrect JavaScript #3527

Closed
3p3r opened this issue Apr 22, 2022 · 2 comments · Fixed by #3528
Closed

entire CDK: NPM bundle includes semantically incorrect JavaScript #3527

3p3r opened this issue Apr 22, 2022 · 2 comments · Fixed by #3528
Labels

Comments

@3p3r
Copy link

3p3r commented Apr 22, 2022

Describe the bug

invalid bundles with semantically incorrect JavaScript are being published to npm.

following files are affected:

node_modules/aws-cdk-lib/aws-apigateway/lib/integrations/aws.js:1:512: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-apigateway/lib/integrations/http.js:1:442: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-apigateway/lib/integrations/lambda.js:1:607: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-apigateway/lib/lambda-api.js:1:452: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-apigateway/lib/restapi.js:1:1109: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-apigateway/lib/stepfunctions-api.js:1:515: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-applicationautoscaling/lib/target-tracking-scaling-policy.js:1:606: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-autoscaling/lib/target-tracking-scaling-policy.js:1:547: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-codepipeline-actions/lib/codecommit/source-action.js:1:891: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-codepipeline-actions/lib/codedeploy/ecs-deploy-action.js:1:562: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-config/lib/managed-rules.js:1:2345: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-docdb/lib/database-secret.js:1:484: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-ec2/lib/client-vpn-authorization-rule.js:1:482: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-ec2/lib/client-vpn-route.js:1:959: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-ecs/lib/ec2/ec2-service.js:1:645: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-ecs/lib/external/external-service.js:1:602: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-ecs/lib/fargate/fargate-service.js:1:603: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-eks/lib/oidc-provider.js:1:434: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-listener.js:1:1007: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-target-group.js:1:833: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-elasticloadbalancingv2/lib/nlb/network-listener.js:1:807: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-elasticloadbalancingv2/lib/nlb/network-target-group.js:1:671: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-events/lib/event-bus.js:1:916: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-kms/lib/alias.js:1:1162: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:628: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-rds/lib/database-secret.js:1:528: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/aws-route53-targets/lib/api-gateway-domain-name.js:1:1234: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/core/lib/nested-stack.js:1:879: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()
node_modules/aws-cdk-lib/core/lib/stack.js:1:1360: ERROR - [JSC_THIS_BEFORE_SUPER] cannot access this before calling super()

I tracked it down and seems like this snippet in all of these files are causing them to throw:

Error.captureStackTrace(error, this.constructor);

some times it looks like this:

Error.captureStackTrace(error,this.bind)

which indeed does try to access this before super is called in all of those files. this JavaScript is semantically incorrect and should throw in "strict" mode.

Expected Behavior

CDK should not include semantically incorrect JavaScript.

Current Behavior

CDK includes semantically incorrect JavaScript and causes applications in "strict" mode to fail.

Reproduction Steps

npm i aws-cdk

Possible Solution

collection of stack trace should happen after super() is called.

Additional Information/Context

I caught this in cdk-web's pipeline after dependabot opened a PR with the new release.

CDK CLI Version

2.21.0 (build 3f74a81)

Framework Version

No response

Node.js Version

v16.14.2

OS

Ubuntu 18

Language

Typescript

Language Version

No response

Other information

this issue only showed up in the latest version 2.21.0

@3p3r 3p3r added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 22, 2022
@3p3r 3p3r changed the title entire CDK: NPM bundle include semantically incorrect JavaScript entire CDK: NPM bundle includes semantically incorrect JavaScript Apr 22, 2022
@Suis94
Copy link

Suis94 commented Apr 22, 2022

4C7B10E6-7E43-4973-987B-D00277C7612A

@peterwoodworth peterwoodworth removed the needs-triage This issue or PR still needs to be triaged. label Apr 27, 2022
@rix0rrr rix0rrr transferred this issue from aws/aws-cdk May 9, 2022
@rix0rrr rix0rrr removed their assignment May 9, 2022
@mergify mergify bot closed this as completed in #3528 May 9, 2022
mergify bot pushed a commit that referenced this issue May 9, 2022
…uper (#3528)

Instead of using `this.constructor`, inline the class name (which has
the same value as `this.constructor` anyway). This removes what can be
seen as a semantic issue (as it is usually illegal to refer to `this`
before having called `super` in strict mode).

Fixes #3527 

---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants