Chromium Process Locking and not Cleaned Up



  • Getting this issue repeatedly when deploying to a development environment. We deploy to a Windows server and host our MVC/Razor service in IIS. Here's how we add jsreport:

            services.AddJsReport(new LocalReporting().UseBinary(JsReportBinary.GetBinary())
                .KillRunningJsReportProcesses().AsUtility().Create());
    

    We're generating PDFs using the Chrome PDF engine.

    The first few PDF generations will work just fine. However after some amount of time (most likely after IIS has automatically recycled the application pool), PDFs stop generating with the exception below.

    I can fix this by stopping any Chromium processes leftover (they are hanging around when they aren't supposed to it seems and locking the temp directory), deleting the jsreport temp directory automatically created in C:\Windows\Temp, and recycling the app pool again, but eventually it occurs again.

    The stack trace:

    jsreport.Local.JsReportBinaryException: Error rendering report: A critical error occurred while trying to execute the render command: An error occurred while trying to start daemonized process: An error has occurred when trying to initialize jsreport (2). EBUSY: resource busy or locked, open 'C:\Windows\TEMP\jsreport\jsreport\compile\jsreport-2.5.0-BymsTkv0E\chrome\chrome.exe' (1). caused by error (2) -> meta = {"code":"EBUSY"}, stack = Error: at instance.init.then.catch ([eval]:66283:29) at tryCatcher (jsreportRuntime.js:158306:23) at Promise._settlePromiseFromHandler (jsreportRuntime.js:157998:31) at Promise._settlePromise (jsreportRuntime.js:158055:18) at Promise._settlePromise0 (jsreportRuntime.js:158100:10) at Promise._settlePromises (jsreportRuntime.js:158176:18) at _drainQueueStep (jsreportRuntime.js:39442:12) at _drainQueue (jsreportRuntime.js:39435:9) at Async._drainQueues (jsreportRuntime.js:39451:5) at Immediate.Async.drainQueues (jsreportRuntime.js:39321:14) at runCallback (timers.js:794:20) at tryOnImmediate (timers.js:752:5) at processImmediate [as _immediateCallback] (timers.js:729:5)caused by error (1) -> meta = {"errno":-4082,"code":"EBUSY","syscall":"open","path":"C:\Windows\TEMP\jsreport\jsreport\compile\jsreport-2.5.0-BymsTkv0E\chrome\chrome.exe"}, stack = Error: (1). caused by error (1) -> meta = {"code":"EBUSY"}, stack = Error: at exports.NsSocket.socket.dataOnce ([eval]:66671:25) at exports.NsSocket.listener ([eval]:13402:10) at exports.NsSocket.EventEmitter.emit ([eval]:13490:22) at exports.NsSocket._onData ([eval]:94250:8) at Lazy.<anonymous> ([eval]:74361:13) at Lazy.<anonymous> ([eval]:74343:19) at emitTwo (events.js:126:13) at Lazy.emit (events.js:214:7) at Lazy.<anonymous> ([eval]:74344:22) at emitOne (events.js:116:13) at Lazy.emit (events.js:211:7) at yieldTo ([eval]:74451:18) at Function.<anonymous> ([eval]:74489:27) at Lazy.<anonymous> ([eval]:74457:21) at emitOne (events.js:116:13) at Lazy.emit (events.js:211:7)
    at jsreport.Local.Internal.LocalUtilityReportingService.RenderAsync(String requestString, CancellationToken ct)
    at jsreport.AspNetCore.JsReportMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
    at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
    at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
    at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
    at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
    at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
    at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.InvokeCore(HttpContext context)
    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

    Any help you could give into why this is happening would be great!



  • There were some improvements regarding this problem implemented in jsreport 2.6.1
    Please update the jsreport.Binary nuget to the 2.6.1



  • Thank you for the quick response! I updated jsreport.Binary to 2.6.1, however we are still encountering errors. We get this exception now with the same circumstances where the Chromium processes can't be cleaned up properly and begin to lock the chrome.exe that lives in the jsreport temp directory:

    JsReportBinaryException: Error rendering report: A critical error occurred while trying to execute the render command: An error occurred while trying to start daemonized process: An error has occurred when trying to initialize jsreport (2). EBUSY: resource busy or locked, open 'C:\inetpub\wwwroot\ServiceName\jsreport\temp\compile\jsreport-2.6.1-HkSd-6jOS\chrome\chrome.exe' (1). caused by error (2) -> meta = {"code":"EBUSY"}, stack = Error: at exports.initialize.instance.init.then.catch (D:\snapshot\jsreport\node_modules\jsreport-cli\lib\instanceHandler.js:31:29)caused by error (1) -> meta = {"errno":-4082,"code":"EBUSY","syscall":"open","path":"C:\inetpub\wwwroot\ServiceName\jsreport\temp\compile\jsreport-2.6.1-HkSd-6jOS\chrome\chrome.exe"}, stack = Error: (1). caused by error (1) -> meta = {"code":"EBUSY","disableExit":false}, stack = Error: at exports.NsSocket.module.exports.socket.dataOnce (D:\snapshot\jsreport\node_modules\jsreport-cli\lib\keepAliveProcess.js:135:25) at exports.NsSocket.listener (D:\snapshot\jsreport\node_modules\eventemitter2\lib\eventemitter2.js:251:10) at exports.NsSocket.EventEmitter.emit (D:\snapshot\jsreport\node_modules\eventemitter2\lib\eventemitter2.js:339:22) at exports.NsSocket._onData (D:\snapshot\jsreport\node_modules\nssocket\lib\nssocket.js:454:8) at Lazy.<anonymous> (D:\snapshot\jsreport\node_modules\lazy\lazy.js:91:13) at Lazy.<anonymous> (D:\snapshot\jsreport\node_modules\lazy\lazy.js:73:19) at Lazy.emit (events.js:189:13) at Lazy.<anonymous> (D:\snapshot\jsreport\node_modules\lazy\lazy.js:74:22) at Lazy.emit (events.js:189:13) at yieldTo (D:\snapshot\jsreport\node_modules\lazy\lazy.js:181:18)

    I also updated our AddJsReport method to the following:

            services.AddJsReport(new LocalReporting()
                .UseBinary(JsReportBinary.GetBinary())
                .Configure(cfg =>
                {
                    cfg.AllowedLocalFilesAccess();
                    cfg.FileSystemStore();
                    cfg.BaseUrlAsWorkingDirectory();
                    cfg.HttpPort = 1000;
                    cfg.TempDirectory = Path.Combine(_environment.ContentRootPath, "jsreport", "temp");
                    return cfg;
                })
                .KillRunningJsReportProcesses()
                .RunInDirectory(Path.Combine(_environment.ContentRootPath, "jsreport"))
                .AsUtility()
                .Create());


  • I apologize for your trouble. We took a look again in more detail today and fixed a problem with parallel chrome extraction.

    I prepared for you an updated jsreport.Binary nuget package. It would be really great if you can try it out.
    https://1drv.ms/u/s!AogtKyPn-GjbhK5apIgkVrrYP1bpow?e=LoHAz8



  • Wow, thank you for the quick turnaround! Unfortunately it seems that OneDrive link doesn't work for me. It says something went wrong when I try to open it





  • Is it possible to do this as a pre-release version of the jsreport.Binary package? Due to our security policies and firewall I most likely won't be able to download an external package this way. I'm sorry for the inconvenience, and thank you again for the help.



  • This issue ended up being resolved for a different reason that I can't quite explain why. By upgrading from version 2.2.6 of the .NET Core Hosting Bundle on the affected machine to version 2.2.7, we resolved this.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.