sjudson / paseto.js

PASETO: Platform-Agnostic Security Tokens
MIT License
269 stars 16 forks source link

Node 16 install issue #39

Closed kjvarga closed 2 years ago

kjvarga commented 2 years ago

Hi there,

This may not be an issue with Paseto.js itself. It's hard to tell. I have successfully installed this package under Node 16 on my local, and in the CircleCI cimg/node:16.13.0 image. However, when building the image for deployment using the aws-ecr/default executor in CircleCI I get the following build failure from node-gyp. If you have any insights that would be helpful. Otherwise I'll try to debug the issue and get access to the detailed build error(s).

Sending build context to Docker daemon  11.46MB
Step 1/14 : FROM ********************************************/change/base/node:16-builder AS builder
16-builder: Pulling from change/base/node

a0d46f8b: Pulling fs layer 
0ad1b361: Pulling fs layer 
44ac7415: Pulling fs layer 
f63b29cb: Pulling fs layer 
Digest: sha256:c982c8240f42ec7f0164fd8961f7ce21e8d72a4560ece601d21b4e6d405fd0fa
Status: Downloaded newer image for ********************************************/change/base/node:16-builder
 ---> 2e2f03acea78
Step 2/14 : ARG AWS_ACCESS_KEY_ID
 ---> Running in 0ad4abf9469b
Removing intermediate container 0ad4abf9469b
 ---> 1bec70c542e1
Step 3/14 : ARG AWS_SECRET_ACCESS_KEY
 ---> Running in 00f06a1b2c85
Removing intermediate container 00f06a1b2c85
 ---> 8ae8747c1304
Step 4/14 : RUN /root/.local/bin/aws --region=********* secretsmanager get-secret-value --secret-id build/keys/change-build |         jq '.SecretString' -r > /root/.ssh/id_rsa     && chmod 0600 /root/.ssh/id_rsa
 ---> Running in 5d15910be1d2
Removing intermediate container 5d15910be1d2
 ---> 3c27f564c642
Step 5/14 : COPY package* /**********************/
 ---> fe58d2f34f45
Step 6/14 : WORKDIR /**********************/
 ---> Running in 64a25e6b8b7c
Removing intermediate container 64a25e6b8b7c
 ---> 76f7c8d4b688
Step 7/14 : RUN npm clean-install
 ---> Running in cc9a80e34dd5
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated formidable@1.2.2: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated core-js@2.6.11: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm notice 
npm notice New patch version of npm available! 8.1.0 -> 8.1.3
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.1.3>
npm notice Run `npm install -g npm@8.1.3` to update!
npm notice 
npm ERR! code 1
npm ERR! path /**********************/node_modules/paseto.js
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/**********************/node_modules/paseto.js/build'
npm ERR! make: Leaving directory '/**********************/node_modules/paseto.js/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.2.0
npm ERR! gyp info using node@16.13.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.5 found at "/usr/bin/python3"
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.13.0/SHASUMS256.txt
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.13.0/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/**********************/node_modules/paseto.js/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/16.13.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.13.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/**********************/node_modules/paseto.js',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! make: printf: Operation not permitted
npm ERR! make: *** [extcrypto_addon.target.mk:113: Release/obj.target/extcrypto_addon/extcrypto/extcrypto.o] Error 127
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 5.4.0-1025-aws
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /**********************/node_modules/paseto.js
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v8.2.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-11-11T01_29_41_964Z-debug.log
The command '/bin/sh -c npm clean-install' returned a non-zero code: 1

When building the same image on my local Mac OSX, it works. Which makes me think there is something about the version of Docker, or some other difference in the setup, that is causing the build failure.

If there's any information you can provide that explains why Paseto.js is not the issue here, or any information around Node 16 support, that would be helpful for me to narrow down the issue. Thanks!

The executor that fails:

executor: aws-ecr/default
...
  - aws-ecr/build-and-push-image:
      repo: << parameters.ecr_repository >>
      tag: ${TAGS}
      extra-build-args: --target=runner --build-arg AWS_ACCESS_KEY_ID --build-arg AWS_SECRET_ACCESS_KEY --build-arg BUNDLE_RUBYGEMS__PKG__GITHUB__COM
...
kjvarga commented 2 years ago

I was using Paseto.js v0.1.6. I'll try with 0.1.7

kjvarga commented 2 years ago

This still fails. And it's difficult to debug in the executor environment so I haven't made any progress since. Any help appreciated.

kjvarga commented 2 years ago

FYI @sjudson we solved this problem by switching to Debian-based images rather than Linux. The failures magically resolved. We only made the change because of an unrelated issue, so this was a lucky outcome.