TypeError: Cannot read properties of undefined (reading 'log') after adding second PSU node

Product: PowerShell Universal
Version: 4.0.10

Hi all, we added a second PSU node recently (both Windows Server) and job output is no longer working correctly in the admin console:

TypeError: Cannot read properties of undefined (reading 'log')

    at v (https://webaddress/admin/static/js/36.94cfc862.chunk.js:1:16258)
    at div
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:1017995
    at k (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:112809)
    at div
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:3035540
    at T (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:112579)
    at n (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:3135592)
    at Suspense
    at u (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:9343)
    at m (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:112075)
    at g (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:112253)
    at U (https://webaddress/admin/static/js/24.c26844df.chunk.js:1:10683)
    at d (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:388526)
    at p (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:388854)
    at p
    at d (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:388526)
    at p (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:388854)
    at n (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:3135592)
    at Suspense
    at u (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:9343)
    at main
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:923119
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:922950
    at section
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:923354
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:922950
    at div
    at div
    at t (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:2905562)
    at Oe (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:164766)
    at section
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:923354
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:922950
    at section
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:923354
    at https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:922950
    at Wt (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:187467)
    at d (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:388526)
    at p (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:388854)
    at h (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:388591)
    at u (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:376639)
    at n (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:3135592)
    at Suspense
    at u (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:9343)
    at m (https://webaddress/admin/static/js/main.31a3a517.chunk.js:1:154850)
    at s (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:954224)
    at c (https://webaddress/admin/static/js/18.c249edd3.chunk.js:2:679331)
    at ya

Output seems to be there for only the most recent jobs, and appear as JSON strings [{“…”}] before they eventually go missing and start throwing the above stacktrace.

Tried changing the logging targets around, currently we only target the database, which is Azure SQL with the PSU service account being an owner. Any ideas?

Also found this in systemLog.txt:

2023-08-24 09:38:44.855 +02:00 [ERR] An unhandled exception has occurred while executing the request.
Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: [. Path '', line 1, position 502.
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at UniversalAutomation.JobController.GetLogOutput(Job job, String format, String timezone, Boolean stream) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Controllers\JobController.cs:line 478
   at UniversalAutomation.JobController.GetLogOutput(Int64 id, String timezone, String format, Boolean stream) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Controllers\JobController.cs:line 401
   at lambda_method8524(Closure, Object, Object[])
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at PowerShellUniversal.PSUMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Middleware\PowerShellMiddleware.cs:line 44
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at PowerShellUniversal.FeatureMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Middleware\FeatureMiddleware.cs:line 43
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at PowerShellUniversal.DisallowedModeMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Middleware\ModeMiddleware.cs:line 47
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at PowerShellUniversal.CspMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Middleware\CspMiddleware.cs:line 21
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Universal.Server.Middleware.RoutingMiddleware.Invoke(HttpContext httpContext, IPolicyEvaluator policyEvaluator) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Middleware\RoutingMiddleware.cs:line 202
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Universal.Server.Middleware.SwaggerAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Middleware\SwaggerAuthMiddleware.cs:line 37
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context) in C:\actions-runner\_work\universal\universal\src\AspNetCoreRateLimit\Middleware\RateLimitMiddleware.cs:line 110
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

Looks like where having a simular problem. Fresh installed server 4.0.10 (MSI).
Using SQL (on-site) .
No second node yet.

Same issue here, no second node. Seems to be a bug in 4.0.10

It looks to be duplicating the json being inserted into the JobLog table. Ive been able to make the log readable by running this command to just remove half of the value stored in the column against the JobID:

UPDATE JobLog 
SET [Log] = LEFT([Log], LEN([Log]) / 2)
FROM JobLog 
WHERE Id = 1073 

Not exactly ideal.
@adam

looks like 4.0.12 solved it :+1: