question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when loading native node binary into job

See original GitHub issue

Hi, I’m trying to use a native Node library called Sharp (for image processing) in a webjob. The webjob is deployed as part of my Azure App Service instance and not as a Functions app.

When running the job, I get the following error:

Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.ProcessImages ---> System.Exception: Error: A dynamic link library (DLL) initialization routine failed.
 \\?\D:\local\Temp\jobs\continuous\scripthost\mvhbfltp.51e\ProcessImages\node_modules\sharp\build\Release\sharp.node at Error (native) at Object.Module._extensions..node (module.js:583:18) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at Object.<anonymous> (D:\local\Temp\jobs\continuous\scripthost\mvhbfltp.51e\ProcessImages\node_modules\sharp\index.js:12:13) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at Object.<anonymous> (D:\local\Temp\jobs\continuous\scripthost\mvhbfltp.51e\ProcessImages\index.js:11:15) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.require (module.js:483:17)
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.<Invoke>d__23.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.<InvokeAsync>d__0.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<InvokeAsync>d__53.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithWatchersAsync>d__3b.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLoggingAsync>d__36.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLoggingAsync>d__1a.MoveNext()
 --- End of inner exception stack trace ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLoggingAsync>d__1a.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<TryExecuteAsync>d__2.MoveNext()

I’m running Node 6.9.1 x64 on Azure. When I compile the application on Appveyor, I’m also using Node 6.9.1 x64. Compilation works great, it’s just the error above at runtime.

To be sure this wasn’t an issue with the library itself, I created a test endpoint that utilizes the library in my main application and it works as expected.

Repro steps

Provide the steps required to reproduce the problem

  1. Install 64-bit Node and setup app service to run it
  2. Create a webjob that attempts to access the Sharp library.
  3. Run the job

Expected behavior

The job runs without error.

Actual behavior

The job fails with the above error.

Related information

I’m running the Functions 1.0.10635 runtime, but have also tried with the previous version.

Here’s a link to the source for the job: https://gist.github.com/jamesdixon/ba35960d7a64890eda49cc78a68cf424

Thank you!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
abramzcommented, Jun 21, 2018

This is quite old but still an open issue, are there any updates?

0reactions
mamasocommented, Jan 18, 2017

I filed an issue, it’s not necessarily a bug.

Edge has some minimal documentation describing that ‘native modules must be linked against the node.dll that edge uses’. I’ve tried various configurations with node-gyp and my own test native module to no avail on that front.

Even if that is successful, native modules will not work out of the npm install box - we or the user would need to rebuild the native module to link against edge’s node.dll.

@christopheranderson seems to remember having some success with native modules & functions in the past (in particular bcrypt) so I’ve asked him to follow up with that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native ios build : Can't find node
During the build, the node binary cannot be found, even though Xcode builds are working with regular (non-Expo) React Native projects.- Both ...
Read more >
Can't find 'node' binary to build React Native bundle #22918
Hey, this looks like an environment issue. 'Can't find node binary' is triggered when the Node.js installation is invalid. Try checking your ...
Read more >
Native Node Modules
Modules that rely on prebuild ​ prebuild provides a way to publish native Node modules with prebuilt binaries for multiple versions of Node...
Read more >
CommonJS modules | Node.js v20.5.1 Documentation
CommonJS modules are the original way to package JavaScript code for Node.js. ... If X/index.node is a file, load X/index.node as binary addon....
Read more >
Error: cannot find module [Node npm Error Solved]
I'm getting the error because I'm trying to import the freeCodeCamp icon from the react-icons package, which I don't have installed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found