laverdet/node-fibers

Build error on alpine

Closed this issue · 10 comments

First of all, thanks for updating Fibers for Node 12.

I am not able to use fibers in an Alpine based Node 12 container.

I am running Node in a container based on Alpine (node:12-alpine). When I run npm install fibers, the first few lines tell that the musl binary is corrupt:

> fibers@4.0.0 install /tmp/node_modules/fibers
> node build.js || nodejs build.js

`linux-x64-72-musl` exists; testing
Problem with the binary; manual build incoming

The build continues with a few warnings (no errors as far as I can tell). See the logs at the bottom.

However, when I run npm test afterwards from the fibers directory, all tests fail with this error:

already-running.js: *fail*
code: 1
stderr: ## There is an issue with `node-fibers` ##
`/tmp/node_modules/fibers/bin/linux-x64-72-musl/fibers.node` is missing.

Try running this to fix the issue: /usr/local/bin/node /tmp/node_modules/fibers/build
Error: Error relocating /tmp/node_modules/fibers/bin/linux-x64-72-musl/fibers.node: _ZN2v88internal7Isolate14thread_id_key_E: symbol not found
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:800:18)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/tmp/node_modules/fibers/fibers.js:14:39)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
/tmp/node_modules/fibers/fibers.js:23
		throw new Error('Missing binary. See message above.');
		^

Error: Missing binary. See message above.
    at Object.<anonymous> (/tmp/node_modules/fibers/fibers.js:23:9)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/tmp/node_modules/fibers/test/already-running.js:2:13)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)

The binary is there however:

/tmp/node_modules/fibers # ls -l /tmp/node_modules/fibers/bin/linux-x64-72-musl/fibers.node
-rwxr-xr-x    1 root     root         62648 Apr 30 10:32 /tmp/node_modules/fibers/bin/linux-x64-72-musl/fibers.node

build log:

make: Entering directory '/tmp/node_modules/fibers/build'
  CXX(target) Release/obj.target/fibers/src/fibers.o
../src/fibers.cc: In function 'void uni::SetAccessor(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::String>, uni::FunctionType (*)(v8::Local<v8::String>, const GetterCallbackInfo&), void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const SetterCallbackInfo&))':
../src/fibers.cc:362:87: warning: cast between incompatible function types from 'uni::FunctionType (*)(v8::Local<v8::String>, const GetterCallbackInfo&)' {aka 'void (*)(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&)'} to 'v8::AccessorNameGetterCallback' {aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&)'} [-Wcast-function-type]
   object->SetAccessor(isolate->GetCurrentContext(), name, (AccessorNameGetterCallback)getter, (AccessorNameSetterCallback)setter).ToChecked();
                                                                                       ^~~~~~
../src/fibers.cc:362:123: warning: cast between incompatible function types from 'void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const SetterCallbackInfo&)' {aka 'void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&)'} to 'v8::AccessorNameSetterCallback' {aka 'void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&)'} [-Wcast-function-type]
   object->SetAccessor(isolate->GetCurrentContext(), name, (AccessorNameGetterCallback)getter, (AccessorNameSetterCallback)setter).ToChecked();
                                                                                                                           ^~~~~~
../src/fibers.cc: In static member function 'static void Fiber::Init(v8::Local<v8::Object>)':
../src/fibers.cc:899:32: warning: 'bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)' is deprecated: Use maybe version [-Wdeprecated-declarations]
    target->Set(sym_yield, yield);
                                ^
In file included from /root/.node-gyp/12.0.0/include/node/v8-internal.h:14,
                 from /root/.node-gyp/12.0.0/include/node/v8.h:25,
                 from /root/.node-gyp/12.0.0/include/node/node.h:63,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/root/.node-gyp/12.0.0/include/node/v8.h:3359:26: note: declared here
                     bool Set(Local<Value> key, Local<Value> value));
                          ^~~
/root/.node-gyp/12.0.0/include/node/v8config.h:322:3: note: in definition of macro 'V8_DEPRECATE_SOON'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/fibers.cc:903:28: warning: 'bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)' is deprecated: Use maybe version [-Wdeprecated-declarations]
    fn->Set(sym_yield, yield);
                            ^
In file included from /root/.node-gyp/12.0.0/include/node/v8-internal.h:14,
                 from /root/.node-gyp/12.0.0/include/node/v8.h:25,
                 from /root/.node-gyp/12.0.0/include/node/node.h:63,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/root/.node-gyp/12.0.0/include/node/v8.h:3359:26: note: declared here
                     bool Set(Local<Value> key, Local<Value> value));
                          ^~~
/root/.node-gyp/12.0.0/include/node/v8config.h:322:3: note: in definition of macro 'V8_DEPRECATE_SOON'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/fibers.cc:909:58: warning: 'bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)' is deprecated: Use maybe version [-Wdeprecated-declarations]
    target->Set(uni::NewLatin1Symbol(isolate, "Fiber"), fn);
                                                          ^
In file included from /root/.node-gyp/12.0.0/include/node/v8-internal.h:14,
                 from /root/.node-gyp/12.0.0/include/node/v8.h:25,
                 from /root/.node-gyp/12.0.0/include/node/node.h:63,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/root/.node-gyp/12.0.0/include/node/v8.h:3359:26: note: declared here
                     bool Set(Local<Value> key, Local<Value> value));
                          ^~~
/root/.node-gyp/12.0.0/include/node/v8config.h:322:3: note: in definition of macro 'V8_DEPRECATE_SOON'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/fibers.cc: In function 'void init(v8::Local<v8::Object>)':
../src/fibers.cc:927:69: warning: 'v8::Local<v8::Value> v8::Object::Get(v8::Local<v8::Value>)' is deprecated: Use maybe version [-Wdeprecated-declarations]
  if (did_init || !target->Get(uni::NewLatin1Symbol(isolate, "Fiber"))->IsUndefined()) {
                                                                     ^
In file included from /root/.node-gyp/12.0.0/include/node/v8-internal.h:14,
                 from /root/.node-gyp/12.0.0/include/node/v8.h:25,
                 from /root/.node-gyp/12.0.0/include/node/node.h:63,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/root/.node-gyp/12.0.0/include/node/v8.h:3412:55: note: declared here
   V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
                                                       ^~~
/root/.node-gyp/12.0.0/include/node/v8config.h:322:3: note: in definition of macro 'V8_DEPRECATE_SOON'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
../src/fibers.cc: At global scope:
/root/.node-gyp/12.0.0/include/node/node.h:556:43: warning: cast between incompatible function types from 'void (*)(v8::Local<v8::Object>)' to 'node::addon_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)'} [-Wcast-function-type]
       (node::addon_register_func) (regfunc),                          \
                                           ^
/root/.node-gyp/12.0.0/include/node/node.h:590:3: note: in expansion of macro 'NODE_MODULE_X'
   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
   ^~~~~~~~~~~~~
../src/fibers.cc:940:1: note: in expansion of macro 'NODE_MODULE'
 NODE_MODULE(fibers, init)
 ^~~~~~~~~~~
../src/fibers.cc: In instantiation of 'void uni::Return(v8::Persistent<T, v8::NonCopyablePersistentTraits<T> >&, uni::GetterCallbackInfo) [with T = v8::Object; uni::GetterCallbackInfo = v8::PropertyCallbackInfo<v8::Value>]':
../src/fibers.cc:838:45:   required from here
../src/fibers.cc:206:3: warning: 'void v8::ReturnValue<T>::Set(const v8::Persistent<S>&) [with S = v8::Object; T = v8::Value]' is deprecated: Use Global<> instead [-Wdeprecated-declarations]
   info.GetReturnValue().Set(handle);
   ^~~~
In file included from /root/.node-gyp/12.0.0/include/node/node.h:63,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/root/.node-gyp/12.0.0/include/node/v8.h:9990:6: note: declared here
 void ReturnValue<T>::Set(const Persistent<S>& handle) {
      ^~~~~~~~~~~~~~
  CXX(target) Release/obj.target/fibers/src/coroutine.o
../src/coroutine.cc:77:14: warning: 'void* find_thread_id_key(void*)' defined but not used [-Wunused-function]
 static void* find_thread_id_key(void* arg)
              ^~~~~~~~~~~~~~~~~~
  CC(target) Release/obj.target/fibers/src/libcoro/coro.o
  SOLINK_MODULE(target) Release/obj.target/fibers.node
  COPY Release/fibers.node
make: Leaving directory '/tmp/node_modules/fibers/build'
Installed in `/tmp/node_modules/fibers/bin/linux-x64-72-musl/fibers.node`

Hi could you please give version 4.0.1 on npm a try and let me know if it works for you?

@laverdet It's working, thanks!

Hello!

I'm having similar problem with version 5.0.1 in an Alpine container (node:14.19.1-alpine). When I run an app it says:

## There is an issue with `node-fibers` ##
`/usr/src/app/node_modules/fibers/bin/linux-arm64-83-musl/fibers.node` is missing.

Try running this to fix the issue: /usr/local/bin/node /usr/src/app/node_modules/fibers/build
Error: Error relocating /usr/src/app/node_modules/fibers/bin/linux-arm64-83-musl/fibers.node: swapcontext: symbol not found
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/usr/src/app/node_modules/fibers/fibers.js:14:39)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
/usr/src/app/node_modules/fibers/fibers.js:23
		throw new Error('Missing binary. See message above.');
		^

Error: Missing binary. See message above.
    at Object.<anonymous> (/usr/src/app/node_modules/fibers/fibers.js:23:9)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/usr/src/app/node_modules/@bigcommerce/stencil-styles/lib/ScssCompiler.js:3:15)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

Here is a build log:

`linux-arm64-83-musl` exists; testing
Problem with the binary; manual build incoming
gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@14.19.1 | linux | arm64
gyp info find Python using Python version 3.9.7 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/src/app/node_modules/fibers/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.cache/node-gyp/14.19.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/14.19.1',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/14.19.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/usr/src/app/node_modules/fibers',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/usr/src/app/node_modules/fibers/build'
  CXX(target) Release/obj.target/fibers/src/fibers.o
../src/fibers.cc: In function 'void uni::SetAccessor(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::String>, uni::FunctionType (*)(v8::Local<v8::String>, const GetterCallbackInfo&), void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const SetterCallbackInfo&))':
../src/fibers.cc:355:59: warning: cast between incompatible function types from 'uni::FunctionType (*)(v8::Local<v8::String>, const GetterCallbackInfo&)' {aka void (*)(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&)'} to 'v8::AccessorNameGetterCallback' {aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&)'} [-Wcast-function-type]
  355 |   object->SetAccessor(isolate->GetCurrentContext(), name, (AccessorNameGetterCallback)getter, (AccessorNameSetterCallback)setter).ToChecked();
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/fibers.cc:355:95: warning: cast between incompatible function types from 'void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const SetterCallbackInfo&)' {aka 'void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&)'} to 'v8::AccessorNameSetterCallback' {aka 'void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&)'} [-Wcast-function-type]
  355 |   object->SetAccessor(isolate->GetCurrentContext(), name, (AccessorNameGetterCallback)getter, (AccessorNameSetterCallback)setter).ToChecked();
      |                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
../src/fibers.cc: At global scope:
/root/.cache/node-gyp/14.19.1/include/node/node.h:793:7: warning: cast between incompatible function types from 'void (*)(v8::Local<v8::Object>)' to 'node::addon_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)'} [-Wcast-function-type]
  793 |       (node::addon_register_func) (regfunc),                          \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/.cache/node-gyp/14.19.1/include/node/node.h:827:3: note: in expansion of macro 'NODE_MODULE_X'
  827 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/fibers.cc:930:1: note: in expansion of macro 'NODE_MODULE'
  930 | NODE_MODULE(fibers, init)
      | ^~~~~~~~~~~
  CXX(target) Release/obj.target/fibers/src/coroutine.o
  CC(target) Release/obj.target/fibers/src/libcoro/coro.o
  SOLINK_MODULE(target) Release/obj.target/fibers.node
  COPY Release/fibers.node
make: Leaving directory '/usr/src/app/node_modules/fibers/build'
gyp info ok 
Installed in `/usr/src/app/node_modules/fibers/bin/linux-arm64-83-musl/fibers.node`

Hi @laverdet could you please review my comment above ?

This looks like a quirk of your environment that you'll have to troubleshoot yourself. Good luck!

@gorodnov I'm having an almost same issue. Have you found a solution for it?

@gorodnov I'm having an almost same issue. Have you found a solution for it?

No, I haven't.

hey @gorodnov I had same issue with my new mac Apple Chip Apple M1 Moterey 12.2.
It is weird because it has been working with my other mac Catalina Intel Chip.

I don't know if the OS version is related.

I am using node:14-alpine3.15

Error:

#0 0.351 $ vue-cli-service build
#0 1.119 
#0 1.120 -  Building for production...
#0 9.985 ## There is an issue with `node-fibers` ##
#0 9.985 `/app/node_modules/fibers/bin/linux-arm64-83-musl/fibers.node` is missing.

Dockerfile:

FROM node:14-alpine3.15 AS BUILD_IMAGE

WORKDIR /app

COPY ["package.json", "yarn.lock", ".npmrc", "./"]

RUN apk add --no-cache python3 make g++

RUN yarn install

COPY . .

RUN yarn build

# remove unused dependencies
RUN rm -rf node_modules/rxjs/src/ node_modules/rxjs/bundles/ node_modules/rxjs/_esm5/ \
    && rm -rf node_modules/rxjs/_esm2015/ node_modules/swagger-ui-dist/*.map node_modules/couchbase/src/

FROM node:14-alpine3.15

WORKDIR /app

# copy from build image
COPY --from=BUILD_IMAGE /app/node_modules ./node_modules

EXPOSE 8081

CMD ["npm", "run", "serve:docker"]

Another thing, I have another project the uses fibers and this project has been working well.

I guess it is not the best solution, but I had to remove and add fibers to work.

RUN yarn install \
    && yarn remove fibers \
    && yarn global add fibers

Hi @arturvetster Thanks for the idea. I'll try that.