Error when loading native node binary into job
See original GitHub issueHi, 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
- Install 64-bit Node and setup app service to run it
- Create a webjob that attempts to access the Sharp library.
- 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:
- Created 7 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
This is quite old but still an open issue, are there any updates?
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.