-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(lambda-nodejs): Unable to use some packages since move to esbuild #15412
Comments
@adam-nielsen I've tried to take a stab at reproducing this error but have run into trouble getting libnetcdf4 to install. Would you be able to try to set up a smaller reproduction that doesn't depend on a large external library so that someone from the team can easily set it up? I would also appreciate some more information on ".node" files as I haven't been able to find any information on them. |
Many thanks for having a look at this! I have since found the Essentially you can pick any CDK stack and try to add
I don't know much about the .node files but it looks like when you compile a NodeJS plugin (i.e. C++ code that hooks into the Javascript engine) it produces a native code library (like a .dll or .so file) but stores it with a .node extension. It seems that if you point your package entry point to this .node file instead of a .js file, then this library gets loaded into the JS engine. It seems these .node files are produced by the node-gyp tool, which is the official way of building native modules on various operating systems. That's about the extent of what I could find out from my research, as I've never written a module like this, only consumed them like any other NodeJS module. |
I had this issue a while back deploying lambda@edge with the sharp module as it also has native dependencies. You're spot on about the compiled native outputs, they're binaries which is why you can't actually bundle them into your js the way esbuild wants. I took a stab at solving your issue using the sample you provided. When I tried to download that Here's the version I got working. Not sure if this helps you out or not |
Thanks @privogpynes for looking and helping out on this. @adam-nielsen - can you check if this helps you? |
My apologies I meant to look at this sooner! Yes, it does appear to have fixed the problem, although I am not entirely sure how. Part of the issue was that I didn't have my bundling options inside the I also had to adjust some git settings inside the bundling container as it was trying to use SSH to clone a public module from git, but there are no host keys or private keys in the container so it was failing. By forcing it to the HTTPS instead, it can clone without needing any credentials. There also seems to be a bug in CDK that requires you to specify ALL the commandHooks, you can't specify just one. For the record, this is the
In the |
|
This is a continuation of AWS support case 8536830561, where I was advised to open the issue here as it appears to be a bug introduced in a recent CDK change.
Since the move to esbuild, stacks that previously deployed without issue will no longer build. This seems to affect any Lambda function that uses a module that requires a compilation step.
Reproduction Steps
Add to a Lambda:
Try to build it:
Note the module being installed is my own fork of an upstream one modified to compile in a more recent version of Node. I am happy to further modify it to get it to work with esbuild, if that's an option.
There is a minimal working example here: http://uq-ads-aws-support-public.s3-website-ap-southeast-2.amazonaws.com/cdk-bundle-test.zip
It can be run like so:
What did you expect to happen?
I expected it to build and deploy as it did with CDK 1.73.0.
What actually happened?
It failed with an error:
Environment
Other
There appears to be some discussion upstream about this issue however I am not sure whether that proposed fix can be put into CDK.
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: