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 CDK Java "cdk synth" with NodejsFunction construct returns [ERROR] RangeError: Maximum call stack size exceeded #8902

Closed
th3r10n opened this issue Jul 6, 2020 · 9 comments · Fixed by #8907
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@th3r10n
Copy link

th3r10n commented Jul 6, 2020

Executing "cdk synth" on a Java CDK project with a Stack that has a NodejsFunction construct is returning:
[ERROR] RangeError: Maximum call stack size exceeded

CreateCommandRestControllerStack.zip

Reproduction Steps

Synthesize the attached CreateCommandRestControllerStack to see the error. Removing the following construct allows the Stack to be synthesized.

NodejsFunction sendProductEventWrapper = NodejsFunction.Builder
.create(this, "SendProductEventHandler")
.entry("resources/lambda/send-product-event.js")
.handler("handler")
.runtime(Runtime.NODEJS_12_X)
.timeout(Duration.seconds(15))
.build();

Error Log

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project 02-ecom-create-command-rest-controller: An exception occured while executing the Java class. Maximum call stack size exceeded
[ERROR] RangeError: Maximum call stack size exceeded
[ERROR] at Object.join (path.js:1033:7)
[ERROR] at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:47:28)
[ERROR] at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
[ERROR] at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
[ERROR] at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
[ERROR] at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
[ERROR] at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
[ERROR] at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
[ERROR] at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
[ERROR] at Kernel._wrapSandboxCode (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:8391:19)
[ERROR] at Kernel._create (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7915:26)
[ERROR] at Kernel.create (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7659:21)
[ERROR] at KernelHost.processRequest (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7439:28)
[ERROR] at KernelHost.run (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7377:14)
[ERROR] at Immediate._onImmediate (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7380:37)
[ERROR] at processImmediate (internal/timers.js:456:21)
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project 02-ecom-create-command-rest-controller: An exception occured while executing the Java class. Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at Object.join (path.js:1033:7)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:47:28)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at Kernel._wrapSandboxCode (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:8391:19)
at Kernel._create (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7915:26)
at Kernel.create (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7659:21)
at KernelHost.processRequest (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7439:28)
at KernelHost.run (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7377:14)
at Immediate._onImmediate (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7380:37)
at processImmediate (internal/timers.js:456:21)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at Object.join (path.js:1033:7)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:47:28)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at Kernel._wrapSandboxCode (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:8391:19)
at Kernel._create (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7915:26)
at Kernel.create (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7659:21)
at KernelHost.processRequest (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7439:28)
at KernelHost.run (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7377:14)
at Immediate._onImmediate (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7380:37)
at processImmediate (internal/timers.js:456:21)
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:339)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: software.amazon.jsii.JsiiException: Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at Object.join (path.js:1033:7)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:47:28)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at findUp (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-kernel-q4WbAo/node_modules/@aws-cdk/aws-lambda-nodejs/lib/util.js:50:12)
at Kernel._wrapSandboxCode (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:8391:19)
at Kernel._create (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7915:26)
at Kernel.create (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7659:21)
at KernelHost.processRequest (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7439:28)
at KernelHost.run (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7377:14)
at Immediate._onImmediate (/private/var/folders/wq/ntl4l5ws2hb44qtf6ss8x2s40000gn/T/jsii-java-runtime12917045189774538847/jsii-runtime.js:7380:37)
at processImmediate (internal/timers.js:456:21)
at software.amazon.jsii.JsiiRuntime.processErrorResponse(JsiiRuntime.java:119)
at software.amazon.jsii.JsiiRuntime.requestResponse(JsiiRuntime.java:91)
at software.amazon.jsii.JsiiClient.createObject(JsiiClient.java:88)
at software.amazon.jsii.JsiiEngine.createNewObject(JsiiEngine.java:526)
at software.amazon.awscdk.services.lambda.nodejs.NodejsFunction.(NodejsFunction.java:31)
at software.amazon.awscdk.services.lambda.nodejs.NodejsFunction$Builder.build(NodejsFunction.java:706)
at com.myorg.CreateCommandRestControllerStack.(CreateCommandRestControllerStack.java:84)
at com.myorg.CreateCommandRestControllerStack.(CreateCommandRestControllerStack.java:29)
at com.myorg.CreateCommandRestControllerApp.main(CreateCommandRestControllerApp.java:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.base/java.lang.Thread.run(Thread.java:832)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Environment

  • CDK CLI Version : 1.49.1
  • Node.js Version: v12.16.2
  • OS : MacOS 10.12.6
  • Language (Version): Java 14

Other


This is 🐛 Bug Report

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

jogold commented Jul 6, 2020

@th3r10n can you try with an absolute path for your entry?

jogold added a commit to jogold/aws-cdk that referenced this issue Jul 6, 2020
…try file

Use absolute paths in `findUp()` to avoid this.

Fixes aws#8902
@jogold
Copy link
Contributor

jogold commented Jul 6, 2020

@eladb both #8907 and #8874

@mergify mergify bot closed this as completed in #8907 Jul 6, 2020
mergify bot pushed a commit that referenced this issue Jul 6, 2020
…try file path (#8907)

Use absolute paths in `findUp()` to avoid this.

Fixes #8902


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@th3r10n
Copy link
Author

th3r10n commented Jul 7, 2020

I've added the absolute path to the "entry". But now it complaints about:

ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project 02-ecom-create-command-rest-controller: An exception occured while executing the Java class. Cannot find a package.json in this project.

See errors.txt

@jogold
Copy link
Contributor

jogold commented Jul 7, 2020

@th3r10n can you share your folder structure?

@th3r10n
Copy link
Author

th3r10n commented Jul 7, 2020

Here it is @jogold:
command-controller.zip

@jogold
Copy link
Contributor

jogold commented Jul 7, 2020

@th3r10n can you add an "empty" package.json in resources/lambda and test if it works?

{}

The construct currently expects a package.json file to be present somewhere in the folder structure. Will see if we can create one if we don't find it. For 100% JS/TS projects a package.json will always be present somewhere and I haven't thought about this mixed programming languages pattern when initially developing the construct.

@th3r10n
Copy link
Author

th3r10n commented Jul 7, 2020

If I add the package.json(empty i.e. {} or with content) the "cdk synth/deploy" just hangs. Adding -X in cdk.json and then executing cdk synth hangs at:
[DEBUG] Setting accessibility to true in order to invoke main().
See cdk-synth-output.txt
See #8921

@eladb
Copy link
Contributor

eladb commented Jul 7, 2020

@jogold wondering if we should have been more explicit about the project root instead of magically looking for a git repo.

@jogold
Copy link
Contributor

jogold commented Jul 7, 2020

@jogold wondering if we should have been more explicit about the project root instead of magically looking for a git repo.

There two issues here:

  1. finding the project root = the source path of the asset (this is [aws-lambda-nodejs] NodejsFunction broken on v1.48.0 #8837 (comment)?). How about also looking for a cdk.json?
  2. finding a package.json = we need to configure it for parcel. Looks like even with a package.json @th3r10n has a deploy problem, lets continue this discussion in CLI hangs with "unexpected: --output is required" (is it related to NodejsFunction?) #8921.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants