Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: grpc_node.node: invalid ELF header #7236

Closed
stephenplusplus opened this issue Jul 6, 2016 · 12 comments

Comments

Projects
None yet
9 participants
@stephenplusplus
Copy link

commented Jul 6, 2016

From @Nabarun on July 5, 2016 5:11

I have a node.js app which is deployed in heroku. I am using gcloud to query vision related stuff. It works on my local but in heroku it throws following exception. Please help me to resolve this

2016-07-05T04:56:40.742299+00:00 app[web.1]: module.js:440
2016-07-05T04:56:40.742348+00:00 app[web.1]:   return process.dlopen(module, path._makeLong(filename));
2016-07-05T04:56:40.742354+00:00 app[web.1]:                  ^
2016-07-05T04:56:40.742355+00:00 app[web.1]: 
2016-07-05T04:56:40.742356+00:00 app[web.1]: Error: /app/node_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node: invalid ELF header
2016-07-05T04:56:40.742356+00:00 app[web.1]:     at Error (native)
2016-07-05T04:56:40.742357+00:00 app[web.1]:     at Object.Module._extensions..node (module.js:440:18)
2016-07-05T04:56:40.742358+00:00 app[web.1]:     at Module.load (module.js:357:32)
2016-07-05T04:56:40.742358+00:00 app[web.1]:     at Function.Module._load (module.js:314:12)
2016-07-05T04:56:40.742359+00:00 app[web.1]:     at Module.require (module.js:367:17)
2016-07-05T04:56:40.742359+00:00 app[web.1]:     at require (internal/module.js:20:19)
2016-07-05T04:56:40.742360+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/gcloud/node_modules/grpc/src/node/src/grpc_extension.js:38:15)
2016-07-05T04:56:40.742361+00:00 app[web.1]:     at Module._compile (module.js:413:34)
2016-07-05T04:56:40.742361+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:422:10)
2016-07-05T04:56:40.742362+00:00 app[web.1]:     at Module.load (module.js:357:32)
2016-07-05T04:56:40.723358+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/getlogo?url=http://i.forbesimg.com/media/lists/companies/coca-cola_416x416.jpg" host=runu.herokuapp.com request_id=92c7b1f8-be1c-4009-b2a9-73ac8adf81fe fwd="71.202.43.114" dyno=web.1 connect=1ms service=1350ms status=503 bytes=0
2016-07-05T04:56:41.531276+00:00 heroku[web.1]: Process exited with status 1
2016-07-05T04:56:41.516318+00:00 heroku[web.1]: State changed from up to crashed

Copied from original issue: googleapis/google-cloud-node#1409

@stephenplusplus

This comment has been minimized.

Copy link
Author

commented Jul 6, 2016

From @Nabarun on July 5, 2016 5:13

node --version
v4.4.1

@murgatroid99

This comment has been minimized.

Copy link
Member

commented Jul 6, 2016

That error looks like the heroku instance, for some reason, has a non-Linux version of the grpc_node.node file. What is your process for deploying to heroku?

@Nabarun

This comment has been minimized.

Copy link

commented Jul 8, 2016

Here is the process I followed

Download and install the Heroku Toolbelt or learn more about the Heroku Command Line Interface.

If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.

$ heroku login
Clone the repository

Use Git to clone runu's source code to your local machine.

$ heroku git:clone -a runu
$ cd runu
Deploy your changes

Make some changes to the code you just cloned and deploy them to Heroku using Git.

$ git add .
$ git commit -am "make it better"
$ git push heroku master

@murgatroid99

This comment has been minimized.

Copy link
Member

commented Jul 8, 2016

OK, if you're installing the package on a local machine that is not Linux, then copying everything you get to Heroku, I would not expect that to work for this package or any other package with a native extension.

I would recommend following this guide. Specifically, this part is important:

Prevent build artifacts from going into revision control by creating a .gitignore file that looks something like this:

/node_modules
npm-debug.log
.DS_Store
/*.env
@Nabarun

This comment has been minimized.

Copy link

commented Jul 9, 2016

I followed the tutorial, now it is crashing due to different reason on heroku. BTW my local setup is on Mac.

Does gcloud use stream-shift?

'connect-time': '19',
2016-07-09T05:11:12.804935+00:00 app[web.1]: module.js:327
2016-07-09T05:11:12.804961+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-07-09T05:11:12.804956+00:00 app[web.1]: ^
2016-07-09T05:11:12.804955+00:00 app[web.1]: throw err;
2016-07-09T05:11:12.804958+00:00 app[web.1]: Error: Cannot find module 'stream-shift'
2016-07-09T05:11:12.804959+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:325:15)
2016-07-09T05:11:12.804963+00:00 app[web.1]: at Object.Module._extensions..js (module.js:416:10)
2016-07-09T05:11:12.804963+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-09T05:11:12.804957+00:00 app[web.1]:
2016-07-09T05:11:12.804960+00:00 app[web.1]: at Function.Module._load (module.js:276:25)
2016-07-09T05:11:12.804960+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-09T05:11:12.804964+00:00 app[web.1]: at Module.load (module.js:343:32)
2016-07-09T05:11:12.804965+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-09T05:11:12.804962+00:00 app[web.1]: at Object. (/app/node_modules/gcloud/node_modules/duplexify/index.js:4:13)
2016-07-09T05:11:12.804964+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-09T05:11:12.810388+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/getlabels?url=https://make.wordpress.org/core/files/2016/02/2A-3-1.jpg" host=runu.herokuapp.com request_id=a972c855-e0c0-4b1d-a8fd-ea2d915e1c5f fwd="71.202.43.114" dyno=web.1 connect=19ms service=43ms status=503 bytes=0
2016-07-09T05:11:13.601448+00:00 heroku[web.1]: Process exited with status 1

@Nabarun

This comment has been minimized.

Copy link

commented Jul 9, 2016

OK again I am hitting the same invalid ELF issue after importing stream-shift module

2016-07-09T16:15:03.242914+00:00 app[web.1]:
2016-07-09T16:15:03.242917+00:00 app[web.1]: at Module.load (module.js:343:32)
2016-07-09T16:15:03.242913+00:00 app[web.1]: ^
2016-07-09T16:15:03.242915+00:00 app[web.1]: Error: /app/node_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node: invalid ELF header
2016-07-09T16:15:03.242915+00:00 app[web.1]: at Error (native)
2016-07-09T16:15:03.242912+00:00 app[web.1]: return process.dlopen(module, path._makeLong(filename));
2016-07-09T16:15:03.242919+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-07-09T16:15:03.242916+00:00 app[web.1]: at Object.Module._extensions..node (module.js:434:18)
2016-07-09T16:15:03.242920+00:00 app[web.1]: at Object. (/app/node_modules/gcloud/node_modules/grpc/src/node/src/grpc_extension.js:38:15)
2016-07-09T16:15:03.242919+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-09T16:15:03.242921+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-09T16:15:03.242918+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-09T16:15:03.242921+00:00 app[web.1]: at Object.Module._extensions..js (module.js:416:10)
2016-07-09T16:15:03.242922+00:00 app[web.1]: at Module.load (module.js:343:32)

@Nabarun

This comment has been minimized.

Copy link

commented Jul 10, 2016

I kind of solved it by building the app in a linux box. Now everything is working fine. Created a sample app with gcloud. It works seemless. Thanks guys for this wonderful addon. http://runu.herokuapp.com/#/imagedetection

@skymapHans

This comment has been minimized.

Copy link

commented Nov 16, 2016

I thought I should leave a comment on this as I've been struggling with this issue back and forth a bit.
Turns out the problem I was having was that I was using an onbuild docker image which did:
ONBUILD RUN npm install before
ONBUILD COPY . /usr/src/app
And I simply didn't have a .dockerignore to ignore my node_modules folder. Thus after installing dependencies with npm install, it copied my local node_modules, compiled on a windows-machine, onto the Linux VM, effectively overwriting the correct native build of grpc that was already on there.

So just add node_modules to your .dockerignore and it's solved.

@hsaliak

This comment has been minimized.

Copy link
Contributor

commented Nov 16, 2016

@skymapHans thanks for the details - very useful pointers for others who might experience this. I'll leave the issue as closed.

@blackavec

This comment has been minimized.

Copy link

commented Dec 8, 2016

@skymapHans i did what you say but still got the issue.
instead i removed my node_module directory from my project, also added them into .dockerignore and changed my code to this:

# Install app dependencies
ADD package.json /tmp/package.json
RUN cd /tmp && yarn install
RUN cp -ar /tmp/node_modules /usr/local/lib/

ofcourse i used yarn, you guys can change it with npm install

i just copied the dependencies into global directory of nodejs. incase you have another global directory you can copy there

@bellaj

This comment has been minimized.

Copy link

commented Jan 12, 2017

Thank you @skymapHans very much. that was exactly my problem, in the beginning i suspected a file corruption but when i read your answer I've remembered that I've omitted the "node_modules/*
" from the .dockerignore file.

@sdiachenko

This comment has been minimized.

Copy link

commented May 15, 2017

The fast solution for me was to add '.dockerignore' and ignore 'node_modules' there

@lock lock bot locked as resolved and limited conversation to collaborators Oct 2, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.