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(core): Aspects from symlinked modules are not applied #19491

Merged
merged 2 commits into from Mar 22, 2022

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Mar 21, 2022

When construct libraries are purposely symlinked (as opposed of
collectively npm installed), depending on how this is done they may
end up with multiple copies of aws-cdk-lib. If that happens, Aspects
from a different aws-cdk-lib copy than the one providing App will
not be applied.

The reason is the use of Symbol('...') instead of Symbol.for('...')
to keep the list of aspects on the construct object.

  • The first version creates a unique symbol per library, while adding
    a naming hint.
  • The second version deduplicates: all symbols with the same naming
    hint will receive the same symbol.

The second version is necessary to make sure that different copies
of the aws-cdk-lib library store their aspects under the same key.

Fixes #18921, #18778, #19390, #18914

When construct libraries are purposely symlinked (as opposed of
collectively `npm install`ed), depending on how this is done they may
end up with multiple copies of `aws-cdk-lib`. If that happens, Aspects
from a different `aws-cdk-lib` copy than the one providing `App` will
not be applied.

The reason is the use of `Symbol('...')` instead of `Symbol.for('...')`
to keep the list of aspects on the construct object.

- The first version creates a unique symbol per library, while adding
  a naming hint.
- The second version deduplicates: all symbols with the same naming
  hint will receive the same symbol.

The second version is necessary to make sure that different copies
of the `aws-cdk-lib` library store their aspects under the same key.

Fixes #18921, #18778, #19390.
@rix0rrr rix0rrr requested a review from a team March 21, 2022 11:14
@rix0rrr rix0rrr self-assigned this Mar 21, 2022
@gitpod-io
Copy link

gitpod-io bot commented Mar 21, 2022

@github-actions github-actions bot added the @aws-cdk/core Related to core CDK functionality label Mar 21, 2022
@rix0rrr
Copy link
Contributor Author

rix0rrr commented Mar 21, 2022

No test as the fault only manifests in situations we cannot test here.

@rix0rrr rix0rrr added the pr-linter/exempt-test The PR linter will not require test changes label Mar 21, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 21, 2022
Copy link
Contributor

@madeline-k madeline-k left a comment

Choose a reason for hiding this comment

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

Mind. blown. Nice work, @rix0rrr.

@mergify
Copy link
Contributor

mergify bot commented Mar 22, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: e8a678c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit eaeaed7 into master Mar 22, 2022
@mergify mergify bot deleted the huijbers/cross-mod-aspects branch March 22, 2022 22:40
@mergify
Copy link
Contributor

mergify bot commented Mar 22, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality contribution/core This is a PR that came from AWS. pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-core): Aspects are not visited if added via module
3 participants