Giter VIP home page Giter VIP logo

Comments (3)

yegorpetrov avatar yegorpetrov commented on August 24, 2024

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.

sriram-mv avatar sriram-mv commented on August 24, 2024

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.

yegorpetrov avatar yegorpetrov commented on August 24, 2024

@sriram-mv

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.