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

[aws-lambda-nodejs] 1.62.0 - fails to compile #10210

Closed
mbonig opened this issue Sep 7, 2020 · 9 comments
Closed

[aws-lambda-nodejs] 1.62.0 - fails to compile #10210

mbonig opened this issue Sep 7, 2020 · 9 comments
Assignees
Labels
@aws-cdk/aws-lambda-nodejs bug This issue is a bug. effort/small Small work item – less than a day of effort needs-triage This issue or PR still needs to be triaged.

Comments

@mbonig
Copy link
Contributor

mbonig commented Sep 7, 2020

While trying to cdk synth a NodejsFunction construct, it errors:

unable to determine cloud assembly output directory. Assets must be defined indirectly within a "Stage" or an "App" scope

This problem does not exist if I rollback to 1.61.0

Reproduction Steps

Here is a repo that reproduces the problem:

https://github.com/mbonig/nodejs-fails-example

What did you expect to happen?

I expected the synth to work like it did in 1.61.0

What actually happened?

Got an error and the template failed to synth

Environment

  • CLI Version : 1.62.0

  • Framework Version: 1.62.0

  • Node.js Version: v12.16.1

  • OS : Distributor ID: LinuxMint
    Description: Linux Mint 19.3 Tricia
    Release: 19.3
    Codename: tricia

  • Language (Version): Typescript

Other


This is 🐛 Bug Report

@mbonig mbonig added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 7, 2020
@jogold
Copy link
Contributor

jogold commented Sep 8, 2020

Are you sure all your modules are on 1.62.0?

@eladb eladb added effort/small Small work item – less than a day of effort p2 and removed p2 labels Sep 8, 2020
@mbonig
Copy link
Contributor Author

mbonig commented Sep 8, 2020

yes.

@jogold
Copy link
Contributor

jogold commented Sep 9, 2020

@mbonig this is an error from core when outdir cannot be determined. Does a "regular" Lambda function works? I suspect a problem with any construct using assets in your case.

@mbonig
Copy link
Contributor Author

mbonig commented Sep 10, 2020

Works fine with a regular Function.

@jogold
Copy link
Contributor

jogold commented Sep 10, 2020

Works fine with a regular Function.

@mbonig I'm now able to reproduce. Very strange... on it.

This is almost exactly the same https://github.com/jogold/cdk-s3-thumbnail but it works on 1.62.0...

@jogold
Copy link
Contributor

jogold commented Sep 10, 2020

OK I found the issue 😄

For some unknown reason your package-lock.json contains incorrect nested cdk dependencies (see https://github.com/mbonig/nodejs-fails-example/pull/1/files for the diff which fixes it).

This leads to @aws-cdk/assets having another "copy" of @aws-cdk/core than the one used by @aws-cdk/aws-lambda-nodejs (the version is the same though):

image

I think that the multiple copies of @aws-cdk/core break all the Symbol.for/instanceof logic used by core to check if an App is an App:

public static isApp(obj: any): obj is App {
return APP_SYMBOL in obj;
}

@mbonig how did you end up with this package-lock.json?

@eladb you should have a look at this. Issue should be renamed to something like multiple (nested) copies of @aws-cdk/core break the construct tree

@mbonig
Copy link
Contributor Author

mbonig commented Sep 10, 2020

This was a very clean and basic new CDK module. So all I did to get here was a cdk init --language=typescript, an npm i and then started writing code and got errors...

@jogold
Copy link
Contributor

jogold commented Sep 10, 2020

This was a very clean and basic new CDK module. So all I did to get here was a cdk init --language=typescript, an npm i and then started writing code and got errors...

Which version of npm are you using?

I cannot reproduce this. I'm doing:

$ mkdir cdk-lock-file-test
$ cd cdk-lock-file-test
$ npx cdk init --language=typescript
$ npm i @aws-cdk/aws-lambda-nodejs

And then I don't have the nested @aws-cdk/core in @aws-cdk/assets

From this commit mbonig/nodejs-fails-example@25fd365 it looks like it happened during an update from 1.60.0 to 1.62.0.

@mbonig
Copy link
Contributor Author

mbonig commented Sep 10, 2020

Looks like this comes from the bump-cdk tool I had used to upgrade the versions.

Closing this and reviewing the tool. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-nodejs bug This issue is a bug. effort/small Small work item – less than a day of effort needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants