Comments (3)
Ok, it looks like the failure isn't really about the "--production" switch. I now have logs with --debug enabled and I'm seeing this:
2023-10-05 05:47:17,074 | NodejsNpmEsbuildBuilder:NpmInstall failed
Traceback (most recent call last):
File "/root/.local/pipx/venvs/aws-sam-cli/lib/python3.11/site-packages/aws_lambda_builders/workflows/nodejs_npm/actions.py", line 116, in execute
self.subprocess_npm.run(command, cwd=self.install_dir)
File "/root/.local/pipx/venvs/aws-sam-cli/lib/python3.11/site-packages/aws_lambda_builders/workflows/nodejs_npm/npm.py", line 84, in run
raise NpmExecutionError(message=err.decode("utf8").strip())
aws_lambda_builders.workflows.nodejs_npm.npm.NpmExecutionError: NPM Failed: npm WARN config production Use `--omit=dev` instead.
npm ERR! code 1
npm ERR! path /tmp/tmp6vedj3ok/node_modules/esbuild
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! node:internal/errors:865
npm ERR! const err = new Error(message);
npm ERR! ^
npm ERR!
npm ERR! Error: Command failed: /tmp/tmp6vedj3ok/node_modules/esbuild/bin/esbuild --version
npm ERR! at checkExecSyncError (node:child_process:890:11)
npm ERR! at Object.execFileSync (node:child_process:926:15)
npm ERR! at validateBinaryVersion (/tmp/tmp6vedj3ok/node_modules/esbuild/install.js:98:28)
npm ERR! at /tmp/tmp6vedj3ok/node_modules/esbuild/install.js:285:5 {
npm ERR! status: null,
npm ERR! signal: 'SIGSEGV',
npm ERR! output: [ null, Buffer(0) [Uint8Array] [], Buffer(0) [Uint8Array] [] ],
npm ERR! pid: 1891,
npm ERR! stdout: Buffer(0) [Uint8Array] [],
npm ERR! stderr: Buffer(0) [Uint8Array] []
npm ERR! }
npm ERR!
npm ERR! Node.js v18.18.0
So actually it's esbuild crashing with a SIGSEGV in its own postinstall action. The "--production" error is there only because the npm builder shows stderr upon non-zero exit code from npm, but essentially it's unrelated.
I now removed esbuild from package.json and left only its globally installed version. And I also call "esbuild --version" just before "sam build" in the CI/CD script to make sure that esbuild is fully installed. Guess what, I'm yet to see any failures.
from aws-lambda-builders.
Is the issue that npm
exits with a non zero exit code, but the relevant work that it needed to do is done anyway?
from aws-lambda-builders.
Is the issue that
npm
exits with a non zero exit code, but the relevant work that it needed to do is done anyway?
I would say that the issue is NodejsNpmEsbuildBuilder "lying" about the error. It shows...
Build Failed
Error: NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm WARN config production Use `--omit=dev` instead.
...which is misleading, because the actual reason is esbuild crashing with a segmentation violation without any traces in stderr. In other words, NodejsNpmEsbuildBuilder should not blindly show the latest stderr output as the reason for build failure. I had to use --debug to find out the true reason after spending hours speculating why "npm WARN config production" could break the build (it didn't).
As for esbuild dying with a SIGSEGV, my workaround was to install and test it (esbuild --version) before running sam build in my CI/CD script. But that's a whole different story.
from aws-lambda-builders.
Related Issues (20)
- Bug: sam build throws error with python packages installed with git+https url HOT 3
- Bug: No message from the Maven's stderr in the sam output logs HOT 1
- Feature request: Include/Exclude Interface for AWS Lambda Builders HOT 3
- German Umlaut in Maven stdout causes SAM build to fail HOT 4
- Can not install custom python dependency from custom git url HOT 4
- Bug: Using AWS::Serverless::LayerVersion with BuildMethod: makefile and python runtime fails to build HOT 2
- [Announcement] Upcoming Runtime Deprecations
- Bug: dnf command does not work on version of public.ecr.aws/lambda/python:3.11-x86_64 publish around 2023.12.05 16:00 UTC HOT 2
- Bug: SourcesContent has no effect when is set to false HOT 5
- Bug: `sam build` and `sam local start-api` always pass `--release` to cargo lambda build HOT 2
- Bug: sam build --use-container fails to install llama-cpp-python on python 3.10 and above HOT 2
- Bug: Cannot build projects with multiple Rust-based Lambdas and using Cargo workspaces HOT 5
- Bug: Building a NodeJS Lambda with husky in the "prepare" script fails HOT 3
- Bug: JavaGradleWorkflow not respecting gradlew with --use-container HOT 4
- Bug: deplyoyment issue with esbuild > 0.22.0 HOT 2
- Feature request: Builder for Javascript with yarn ? HOT 3
- Bug: sam build fails to install onnxruntime==1.18.1 HOT 1
- Bug: git+https requirements fail to install when using python3.12 container HOT 1
- Bug: sam build GoModulesBuilder fails to output the relevant error message, outputs "directory not found" instead HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-builders.