Async Header throwing an error when working with Postgress store.
-
Hey Hopefully you can help us out we are trying to switch from using
options.reports.async
to usingjsreport-Options-Reports-Async
in the header. And when we run things locally without a DB connection all works well. Once we put it in our labs environment using"@jsreport/jsreport-postgres-store"
we get the error bellow. We looked into the odata-to-sql and package but we are a bit stumped as to what would be causing this issue.(because) cannot read properties of undefined (reading 'forEach') TypeError: Cannot read properties of undefined (reading 'forEach') at module.exports (/app/node_modules/@jsreport/odata-to-sql/lib/query.js:54:28) at Object.query (/app/node_modules/@jsreport/odata-to-sql/lib/transformer.js:46:14) at Cursor.toArray (/app/node_modules/@jsreport/sql-store/lib/sqlProvider.js:22:29) at replay (/app/node_modules/@jsreport/jsreport-core/lib/main/store/collection.js:53:21) at /app/node_modules/@jsreport/jsreport-core/lib/main/store/collection.js:60:18 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.findOne (/app/node_modules/@jsreport/jsreport-core/lib/main/store/collection.js:93:17) at async findEntity (/app/node_modules/@jsreport/jsreport-core/lib/main/store/setupValidateShortid.js:63:26) at async validateShortid (/app/node_modules/@jsreport/jsreport-core/lib/main/store/setupValidateShortid.js:45:26) at async ListenerCollection.fire (/app/node_modules/@jsreport/jsreport-core/lib/shared/listenerCollection.js:157:21)
-
Hi, it seems to work for me fine...
Are you on the latest 4.8.0? There was a fix included for the
jsreport-Options-Reports-Async
.
Is there anything specific you do? Authentication enabled, some extra configs... ?
-
We are currently on 4.7.0 we will try upgrading to 4.8.0 and see if that fixes the issue and let you know.
No Authentication enabled.
-
Thanks, upgrading to 4.8.0 fixes that issue.
However, now we are seeing an issue where if we set our workers to 1 it doesn't queue up after the first request everything just runs. Where before we used the header it would queue up but not respond with the location id until a worker was available.
-
But that is expected that with this header you get back the response immediately. The idea is that it doesn't need to wait for available worker to parse the request. Or what am I missing?
-
When only one worker is available and two reports are started one immediately after the other, the expected behavior is that the first report begins execution, while the second receives an immediate response but is queued until the first report finishes. However, in our 4.8.0 testing, we observed that both reports begin running as soon as they are started.
-
Yes, the second report execution will queue. That is what I am observing, see the logs.
2025-04-07T05:11:14.181Z - info: 1 worker threads initialized in 111ms 2025-04-07T05:11:14.181Z - info: Starting temp files cleanup with 180000ms threshold 2025-04-07T05:11:14.182Z - info: reporter initialized 2025-04-07T05:11:17.375Z - info: Responding with async report location and continue with async report generation rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:17.377Z - info: Async report is starting to render 23d579ac-2fd0-4f25-8607-42ed1a5f05f5 2025-04-07T05:11:17.380Z - info: Render request 2 queued for execution and waiting for available worker rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:17.525Z - info: Starting rendering request 2 rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:17.525Z - info: Rendering template { name: test, recipe: chrome-pdf, engine: handlebars, preview: false } rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:17.525Z - debug: Data item not defined for this template. rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:17.529Z - debug: Base url not specified, skipping its injection. rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:17.529Z - debug: Rendering engine handlebars rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:17.949Z - info: Responding with async report location and continue with async report generation rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:17.950Z - info: Async report is starting to render 3630ab9c-6d78-419b-a9cf-2a659b2964d4 2025-04-07T05:11:17.953Z - info: Render request 4 queued for execution and waiting for available worker rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:22.829Z - debug: Executing recipe chrome-pdf rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:23.111Z - debug: Converting with chrome Chrome/133.0.6943.126 using dedicated-process strategy rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:23.142Z - debug: Page request: GET (document) file:///C:/Users/janbl/AppData/Local/Temp/jsreport/autocleanup/f833d045-a92b-4559-a439-8f47388cb2b9-chrome-pdf.html rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:23.150Z - debug: Page request finished: GET (document) 200 file:///C:/Users/janbl/AppData/Local/Temp/jsreport/autocleanup/f833d045-a92b-4559-a439-8f47388cb2b9-chrome-pdf.html rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:23.152Z - debug: Running chrome with params {"printBackground":true,"timeout":44416,"margin":{}} rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:23.291Z - debug: Report stored as reports/test/23d579ac-2fd0-4f25-8607-42ed1a5f05f5.pdf rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:23.291Z - info: Rendering request 2 finished in 5914 ms rootId=nl1z7tegzitxpio, id=nl1z7tegzitxpio 2025-04-07T05:11:23.292Z - info: Async report render finished 23d579ac-2fd0-4f25-8607-42ed1a5f05f5 2025-04-07T05:11:23.294Z - info: Starting rendering request 4 rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:23.294Z - info: Rendering template { name: test, recipe: chrome-pdf, engine: handlebars, preview: false } rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:23.294Z - debug: Data item not defined for this template. rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:23.296Z - debug: Base url not specified, skipping its injection. rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:23.296Z - debug: Rendering engine handlebars rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:28.307Z - debug: Executing recipe chrome-pdf rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:28.477Z - debug: Converting with chrome Chrome/133.0.6943.126 using dedicated-process strategy rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:28.505Z - debug: Page request: GET (document) file:///C:/Users/janbl/AppData/Local/Temp/jsreport/autocleanup/330a112c-dcd5-4ad6-932b-3edad5b73362-chrome-pdf.html rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:28.516Z - debug: Page request finished: GET (document) 200 file:///C:/Users/janbl/AppData/Local/Temp/jsreport/autocleanup/330a112c-dcd5-4ad6-932b-3edad5b73362-chrome-pdf.html rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:28.516Z - debug: Running chrome with params {"printBackground":true,"timeout":39640,"margin":{}} rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:28.652Z - debug: Report stored as reports/test/3630ab9c-6d78-419b-a9cf-2a659b2964d4.pdf rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:28.652Z - info: Rendering request 4 finished in 10702 ms rootId=non6rfa6ar7ajz2, id=non6rfa6ar7ajz2 2025-04-07T05:11:28.653Z - info: Async report render finished 3630ab9c-6d78-419b-a9cf-2a659b2964d4
-
Just confirming that in our testing today, the behavior is as expected. I'm not sure what happened on Friday, but we'll conduct more thorough testing of the queuing feature and follow up if we encounter any issues. Thanks.