Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Incorrect dispose in OutOfProcessNodeInstance #1061

@Yustos

Description

@Yustos

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 37

Inner Exception 1:
Win32Exception: The directory name is invalid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions