Error v.then is not a function while trying to render or download report
I upgraded recently to v3.12.0 and then I tried to use v.4.1.0, I faced the same issue in both of them.
In my code I don't have any v.then, I use awaits and async in all the function, the beforeRender script and the afterRender are both async, I didn't face this issue before using v3.2.0.
A note, we are obliged to upgrade since v3.2.0 contains a lot of memory leak issues.
The error log that I m getting is the following:
jsreport server responded with error. status text: Bad Request, status code: 400, details: Error when evaluating engine handlebars for template /report-x
(because) v.then is not a function
when I checked the base code, seems like this part over here is throwing the error ?
Idk but maybe something that can help, fyi I also tried to comment the async stuff but seems still throwing the same error
I just want to mention that the bug is randomized, sometimes the report is working fine and most of the time throwing that error.
Your help is much appreciated.
This post is deleted!
Please share the content of the failing template helpers section.
Just a function that I m not using in the display or download reports, I m using it just when calling the API.
I m using JS functions using script tag, but even after commenting all the template and the script, it is still random.
What I noticed is that whenever I made a change to the template it works fine and then randomly fails with that error.
Would you be able to email me the export from your workspace and the config file?
Hello Jan, thank you for your reply, I just shared with you the codebase.
There are some async functions, but you can comment them and still the issue is random (I tried to comment the handlebars code as well)
I suggest the following fix:
// here I've changed the last param from `depths` to `[context]`. This was needed to make the ../gotoparent working const v = await spec.main(container, context, container.helpers, container.partials, data, blockParams, [context]) return v.toString()
I made a PR as well https://github.com/jsreport/jsreport/pull/1102.
Is it possible to test it and confirm?
I was checking your export yesterday but wasn't able to replicate the problem so far and I need to first understand what is happening before doing fixes. Unfortunately, your workspace relies on doing external calls so I cannot fully run it in the same context as you do.
The mentioned error could occur only when you run a
xlsxrecipe. I've tried some xlsx templates in your workspace with a load test with thousands of requests but I'm still not able to get the same error. Don't you have better luck in trying to replicate the error without external calls?
Hi Jan, thanks again for your reply.
I sent you another export without the external calls and a video demonstrating the issue. Hope that will help