Hi,
I'm trying to use this library but I keep facing this exception when using version 7 of this library, if I downgrade to 6.3.1 it works fine?
For the avoidance of doubt, I can run node just fine from command line so its definitely on my PATH. I am using .NET 8 (I've tried in .NET 6 and 7 too) and Node 20:
node -v
v20.5.1
dotnet --version
8.0.100
Here is my log output from a small repro:
usingJering.Javascript.NodeJS;usingMicrosoft.Extensions.DependencyInjection;usingMicrosoft.Extensions.Logging;varservices=newServiceCollection();services.AddLogging(loggingBuilder =>{loggingBuilder.SetMinimumLevel(LogLevel.Debug);loggingBuilder.AddConsole();});services.AddNodeJS();StaticNodeJSService.SetServices(services);// InvokestringjavascriptModule=@"module.exports = (callback, x, y) => { // Module must export a function that takes a callback as its first parameter var result = x + y; // Your javascript logic callback(null /* If an error occurred, provide an error object or message */, result); // Call the callback when you're done.}";intresult=awaitStaticNodeJSService.InvokeFromStringAsync<int>(javascriptModule,args:newobject[]{3,5});Console.WriteLine(result);// 8Log:
dbug: Jering.Javascript.NodeJS.HttpNodeJSService[0]
Waiting on process connection semaphore, processID: 81620, thread ID: 1, thread is ThreadPool thread : False.
fail: Jering.Javascript.NodeJS.HttpNodeJSService[0]
The command line is too long.
warn: Jering.Javascript.NodeJS.HttpNodeJSService[0]
An attempt to connect to NodeJS failed. Retries remaining: 2.
Exception:
Jering.Javascript.NodeJS.ConnectionException: Process with ID 81620 exited before connecting.
at Jering.Javascript.NodeJS.OutOfProcessNodeJSService.CreateNewProcessAndConnectAsync()
dbug: Jering.Javascript.NodeJS.HttpNodeJSService[0]
Waiting on process connection semaphore, processID: 74272, thread ID: 11, thread is ThreadPool thread : True.
fail: Jering.Javascript.NodeJS.HttpNodeJSService[0]
The command line is too long.
warn: Jering.Javascript.NodeJS.HttpNodeJSService[0]
An attempt to connect to NodeJS failed. Retries remaining: 1.
Exception:
Jering.Javascript.NodeJS.ConnectionException: Process with ID 74272 exited before connecting.
at Jering.Javascript.NodeJS.OutOfProcessNodeJSService.CreateNewProcessAndConnectAsync()
dbug: Jering.Javascript.NodeJS.HttpNodeJSService[0]
Waiting on process connection semaphore, processID: 83312, thread ID: 11, thread is ThreadPool thread : True.
fail: Jering.Javascript.NodeJS.HttpNodeJSService[0]
The command line is too long.
Unhandled exception. Jering.Javascript.NodeJS.ConnectionException: Process with ID 83312 exited before connecting.
at Jering.Javascript.NodeJS.OutOfProcessNodeJSService.CreateNewProcessAndConnectAsync()
at Jering.Javascript.NodeJS.OutOfProcessNodeJSService.ConnectIfNotConnectedAsync(CancellationToken cancellationToken)
at Jering.Javascript.NodeJS.OutOfProcessNodeJSService.TryInvokeCoreAsync[T](InvocationRequest invocationRequest, CancellationToken cancellationToken)
at Jering.Javascript.NodeJS.OutOfProcessNodeJSService.InvokeFromStringAsync[T](String moduleString, String cacheIdentifier, String exportName, Object[] args, CancellationToken cancellationToken)
Hi,
I'm trying to use this library but I keep facing this exception when using version 7 of this library, if I downgrade to 6.3.1 it works fine?
For the avoidance of doubt, I can run node just fine from command line so its definitely on my PATH. I am using .NET 8 (I've tried in .NET 6 and 7 too) and Node 20:
Here is my log output from a small repro:
Log: