-
Notifications
You must be signed in to change notification settings - Fork 516
Incorrect dispose in OutOfProcessNodeInstance #1061
Description
Please, check nodeProcess field for null in Dispose method of OutOfProcessNodeInstance class.
Problem
If INodeServices invocation (InvokeAsync for example) failed to execute on node process initialization (exception in LaunchNodeProcess), after few seconds (when GC working) exceptions is thrown:
System.NullReferenceException occurred
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.AspNetCore.NodeServices
StackTrace:
at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.Dispose(Boolean disposing)
at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.Dispose(Boolean disposing)
at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.Finalize()
And .NET process crashed.
Steps to reproduce
Usually LaunchNodeProcess method failed, when Node.js not found. But in my case LaunchNodeProcess fail on incorrect project folder.
var options = new NodeServicesOptions(serviceProvider)
{
ProjectPath = NONEXISTENT_PATH
};
_nodeServices = NodeServicesFactory.CreateNodeServices(options);
await _nodeServices.InvokeAsync<string>("./somemodule");
Exception on InvokeAsync any moduleName will:
System.InvalidOperationException occurred
HResult=0x80131509
Message=Failed to start Node process. To resolve this:.[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: C:\Program Files (x86)
Make sure the Node executable is in one of those directories, or update your PATH.[2] See the InnerException for further details of the cause.
Source=Microsoft.AspNetCore.NodeServices
StackTrace:
at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo)
at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance..ctor(String entryPointScript, String projectPath, String[] watchFileExtensions, String commandLineArguments, ILogger nodeOutputLogger, IDictionary2 environmentVars, Int32 invocationTimeoutMilliseconds, Boolean launchWithDebugging, Int32 debuggingPort)
at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance..ctor(NodeServicesOptions options, Int32 port)
at Microsoft.AspNetCore.NodeServices.HostingModels.NodeServicesOptionsExtensions.<>c__DisplayClass0_0.b__0()
at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.CreateNewNodeInstance()
at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.GetOrCreateCurrentNodeInstance()
at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.d__101.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at MailRender.RenderService.d__3.MoveNext() in C:\Projects\MailService\src\mailservice\Mail.Render\RenderService.cs:line 37Inner Exception 1:
Win32Exception: The directory name is invalid