signalfx / splunk-otel-js

Splunk Distribution of OpenTelemetry JavaScript
https://docs.splunk.com/Observability/gdi/get-data-in/application/nodejs/get-started.html
Apache License 2.0
21 stars 13 forks source link

Support for node 20 #759

Closed ChoqueCastroLD closed 1 year ago

ChoqueCastroLD commented 1 year ago

When updating to node 20.4.0 I get this error no matter the otel version I try

npm ERR! code 1
npm ERR! path /Users/luis.choque/Desktop/fakeorders-api/node_modules/@splunk/otel
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! CXX(target) Release/obj.target/metrics/src/native_ext/util/arena.o
npm ERR!   CXX(target) Release/obj.target/metrics/src/native_ext/util/hex.o
npm ERR!   CXX(target) Release/obj.target/metrics/src/native_ext/module.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.4.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.10.0 found at "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3"
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/luis.choque/.nvm/versions/node/v20.4.0/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   '/Users/luis.choque/Desktop/fakeorders-api/node_modules/@splunk/otel/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/luis.choque/.nvm/versions/node/v20.4.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/luis.choque/Library/Caches/node-gyp/20.4.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=/Users/luis.choque/Library/Caches/node-gyp/20.4.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/luis.choque/.nvm/versions/node/v20.4.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/luis.choque/Library/Caches/node-gyp/20.4.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/luis.choque/Desktop/fakeorders-api/node_modules/@splunk/otel',
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! In file included from ../src/native_ext/module.cpp:1:
npm ERR! In file included from ../src/native_ext/metrics.h:3:
npm ERR! In file included from /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8.h:24:
npm ERR! In file included from /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-array-buffer.h:12:
npm ERR! In file included from /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-local-handle.h:12:
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:465:30: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! SHARED_EXTERNAL_POINTER_TAGS(CHECK_SHARED_EXTERNAL_POINTER_TAGS)
npm ERR!                              ^
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:465:30: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:465:30: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:465:30: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:465:30: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! PER_ISOLATE_EXTERNAL_POINTER_TAGS(CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS)
npm ERR!                                   ^
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:466:35: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:693:61: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR!     static_assert(kJSObjectType + 1 == kFirstJSApiObjectType);
npm ERR!                                                             ^
npm ERR!                                                             , ""
npm ERR! /Users/luis.choque/Library/Caches/node-gyp/20.4.0/include/node/v8-internal.h:694:55: error: 'static_assert' with no message is a C++17 extension [-Werror,-Wc++17-extensions]
npm ERR!     static_assert(kJSObjectType < kLastJSApiObjectType);
npm ERR!                                                       ^
npm ERR!                                                       , ""
npm ERR! fatal error: too many errors emitted, stopping now [-ferror-limit=]
npm ERR! 20 errors generated.
npm ERR! make: *** [Release/obj.target/metrics/src/native_ext/module.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
seemk commented 1 year ago

Which compiler/version are you using?

lbeschastny commented 1 year ago

I'm getting the same error on my system:

npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.5.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.10.9 found at "/opt/homebrew/opt/python@3.10/bin/python3.10"
...
npm ERR! gyp ERR! System Darwin 22.5.0
npm ERR! gyp ERR! node -v v20.5.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
lbeschastny commented 1 year ago

Using c++17 instead of c++14 seems to fix this issue:

diff --git a/binding.gyp b/binding.gyp
index 5b7d9f4..9e89fb8 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -37,7 +37,7 @@
         "xcode_settings": {
           "MACOSX_DEPLOYMENT_TARGET": "10.10",
           "OTHER_CFLAGS": [
-            "-std=c++14",
+            "-std=c++17",
             "-stdlib=libc++",
             "-Wall",
             "-Werror"

But there is also a compilation warning in the latest nan: https://github.com/nodejs/nan/issues/953.

So, -Werror also breaks Node.js 20 builds. But this part should not be specific to mac.

lbeschastny commented 1 year ago

I tried running splunk-otel build in CI with those changes and it looks like linux build have some other issues as well:

> @splunk/otel@2.2.4 prebuild:os /__w/splunk-otel-js/splunk-otel-js
> node scripts/prebuild-os.js "20.0.0"

make: Entering directory '/__w/splunk-otel-js/splunk-otel-js/build'
  CXX(target) Release/obj.target/metrics/src/native_ext/util/arena.o
  CXX(target) Release/obj.target/metrics/src/native_ext/util/hex.o
  CXX(target) Release/obj.target/metrics/src/native_ext/module.o
In file included from /tmp/prebuildify/node/20.0.0/include/node/v8-object.h:9:0,
                 from /tmp/prebuildify/node/20.0.0/include/node/v8-array-buffer.h:13,
                 from /tmp/prebuildify/node/20.0.0/include/node/v8.h:24,
                 from ../src/native_ext/splunk_v8.h:[6](https://github.com/lbeschastny/splunk-otel-js/actions/runs/5729232560/job/15525541275#step:6:7),
                 from ../src/native_ext/metrics.h:3,
                 from ../src/native_ext/module.cpp:1:
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:106:40: error: 'is_lvalue_reference_v' is not a member of 'std'
   template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
                                        ^~~
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:106:66: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
   template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
                                                                  ^
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:106:6[7](https://github.com/lbeschastny/splunk-otel-js/actions/runs/5729232560/job/15525541275#step:6:8): error: template argument 1 is invalid
   template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
                                                                   ^
/tmp/prebuildify/node/20.0.0/include/node/v[8](https://github.com/lbeschastny/splunk-otel-js/actions/runs/5729232560/job/15525541275#step:6:9)-maybe.h:106:71: error: expected unqualified-id before '>' token
   template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
                                                                       ^
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:106:71: error: expected constructor, destructor, or type conversion before '>' token
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:123:38: error: 'is_lvalue_reference_v' is not a member of 'std'
 template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
                                      ^~~
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:123:64: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
 template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
                                                                ^
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:123:65: error: template argument 1 is invalid
 template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
                                                                 ^
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:123:70: error: expected unqualified-id before '=' token
 template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
                                                                      ^
/tmp/prebuildify/node/20.0.0/include/node/v8-maybe.h:123:70: error: expected constructor, destructor, or type conversion before '=' token
In file included from ../node_modules/nan/nan.h:60:0,
                 from ../src/native_ext/module.cpp:3:
/tmp/prebuildify/node/20.0.0/include/node/node.h:702:28: error: 'std::string_view' has not been declared
     Environment* env, std::string_view main_script_source_utf8);
                            ^~~~~~~~~~~
In file included from ../src/native_ext/module.cpp:3:0:
../node_modules/nan/nan.h: In function 'bool Nan::IdleNotification(int)':
../node_modules/nan/nan.h:687:32: warning: 'bool v8::Isolate::IdleNotificationDeadline(double)' is deprecated: Use MemoryPressureNotification() to influence the GC schedule. [-Wdeprecated-declarations]
         idle_time_in_ms * 0.001);
                                ^
In file included from /tmp/prebuildify/node/20.0.0/include/node/v8-initialization.h:13:0,
                 from /tmp/prebuildify/node/20.0.0/include/node/v8.h:34,
                 from ../src/native_ext/splunk_v8.h:6,
                 from ../src/native_ext/metrics.h:3,
                 from ../src/native_ext/module.cpp:1:
/tmp/prebuildify/node/20.0.0/include/node/v8-isolate.h:12[9](https://github.com/lbeschastny/splunk-otel-js/actions/runs/5729232560/job/15525541275#step:6:10)3:8: note: declared here
   bool IdleNotificationDeadline(double deadline_in_seconds);
        ^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Release/obj.target/metrics/src/native_ext/module.o] Error 1
metrics.target.mk:126: recipe for target 'Release/obj.target/metrics/src/native_ext/module.o' failed
make: Leaving directory '/__w/splunk-otel-js/splunk-otel-js/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 5.15.0-[10](https://github.com/lbeschastny/splunk-otel-js/actions/runs/5729232560/job/15525541275#step:6:11)41-azure
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--target=20.0.0" "--devdir=/tmp/prebuildify/node" "--arch=x64" "--release"
gyp ERR! cwd /__w/splunk-otel-js/splunk-otel-js
gyp ERR! node -v v14.0.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
node-gyp exited with 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @splunk/otel@2.2.4 prebuild:os: `node scripts/prebuild-os.js "20.0.0"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @splunk/otel@2.2.4 prebuild:os script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /github/home/.npm/_logs/2023-08-01T16_[13](https://github.com/lbeschastny/splunk-otel-js/actions/runs/5729232560/job/15525541275#step:6:14)_[20](https://github.com/lbeschastny/splunk-otel-js/actions/runs/5729232560/job/15525541275#step:6:21)_103Z-debug.log
Error: Process completed with exit code 1.
seemk commented 1 year ago

Version 2.3.1 should fix the issue for Node.js 20, please reopen or let us know if it still happens.