toJSON global helper missing when running in docker



  • I have a template that calls the global helper toJSON. This works fine when running normally. When I switch to run in a docker container (which I need to do for production, Azure environment etc) I get the following error:-
    Error occured - Error during rendering report: Error during rendering report: Missing helper: "toJSON" Stak - Error: Missing helper: "toJSON" at Object. (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19:13) at Object.eval (eval at createFunctionContext (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), :6:89) at main (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32) at ret (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12) at ret (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:525:21) at /usr/src/app/node_modules/jsreport-handlebars/lib/handlebarsEngine.js:25:14 at evalmachine.:1:41 at ContextifyScript.Script.runInContext (vm.js:35:29) at ContextifyScript.Script.runInNewContext (vm.js:41:15) at Object.runInNewContext (vm.js:93:38)

    This has been working fine for many months and only started to go wrong last night. I thought it might be a docker issue so I downgraded to an earlier version that I knew was working. That made no difference so I now believe it's a JSReport issue. Any help much appreciated as I need to run some production reports in the next couple of days.



  • Hm, how do you define the toJSON helper? As an asset? Does the user which is rendering the report have permissions for it?



  • Hi Jan, yes it's an asset. I assume the user rendering the report has permissions as I'm running it and I created it. I've never set permissions before and it has always worked until now but obviously worth checking. Where do I go to check permissions? I've managed to workaround the issue by copying the function to the helper.js for each template but this is obviously not ideal.
    Thanks, Paul



  • If you log in with the user rendering the report, open studio and see the required asset, it would mean you have permissions for it.
    Can you run the template using the Debug button in the studio and paste here the output?



  • Hi Jan, yes I have permissions when running normally and when running in Docker. Here is the output from the debug button:-
    Error occured - Error during rendering report: Error during rendering report: Missing helper: "toJSON" logs (child request): +0 Starting rendering request 9 +12 Rendering template {shortid:HJvscWI8-, recipe:phantom-pdf,engine:handlebars} +13 Adding sample data r1BD6ZUUb +25 Replaced assets ["summary.css"] +26 Resources not defined for this template. +29 Starting rendering request 10 +31 Starting rendering request 11 +48 Starting rendering request 12 +51 Rendering template {shortid:By5KIRDhb, recipe:html,engine:handlebars} +52 Inline data specified. +55 Rendering template {shortid:HysHsW8IW, recipe:html,engine:handlebars} +55 Inline data specified. +58 Rendering template {shortid:HyMy2WI8-, recipe:html,engine:handlebars} +59 Inline data specified. +62 Resources not defined for this template. +71 Replaced assets ["summary.css"] +71 Base url not specified, skipping its injection. +71 Resources not defined for this template. +72 Base url not specified, skipping its injection. +73 Rendering engine handlebars +77 Rendering engine handlebars +106 Replaced assets ["d3.min.js","d3piechart.js"] +107 Resources not defined for this template. +111 Base url not specified, skipping its injection. +112 Rendering engine handlebars +133 Taking compiled template from engine cache +136 Replaced images [] +137 Executing recipe html +137 Skipping storing report. +137 Rendering request finished 11 +137 Rendering request 11 finished in 107 ms +178 Taking compiled template from engine cache +179 Replaced images [] +179 Executing recipe html +180 Skipping storing report. +180 Rendering request finished 10 +181 Rendering request 10 finished in 151 ms logs: +0 Starting rendering request 9 +12 Rendering template {shortid:HJvscWI8-, recipe:phantom-pdf,engine:handlebars} +13 Adding sample data r1BD6ZUUb +25 Replaced assets ["summary.css"] +26 Resources not defined for this template. +29 Starting rendering request 10 +31 Starting rendering request 11 +48 Starting rendering request 12 +51 Rendering template {shortid:By5KIRDhb, recipe:html,engine:handlebars} +52 Inline data specified. +55 Rendering template {shortid:HysHsW8IW, recipe:html,engine:handlebars} +55 Inline data specified. +58 Rendering template {shortid:HyMy2WI8-, recipe:html,engine:handlebars} +59 Inline data specified. +62 Resources not defined for this template. +71 Replaced assets ["summary.css"] +71 Base url not specified, skipping its injection. +71 Resources not defined for this template. +72 Base url not specified, skipping its injection. +73 Rendering engine handlebars +77 Rendering engine handlebars +106 Replaced assets ["d3.min.js","d3piechart.js"] +107 Resources not defined for this template. +111 Base url not specified, skipping its injection. +112 Rendering engine handlebars +133 Taking compiled template from engine cache +136 Replaced images [] +137 Executing recipe html +137 Skipping storing report. +137 Rendering request finished 11 +137 Rendering request 11 finished in 107 ms +178 Taking compiled template from engine cache +179 Replaced images [] +179 Executing recipe html +180 Skipping storing report. +180 Rendering request finished 10 +181 Rendering request 10 finished in 151 ms +218 Error when processing render request Error during rendering report: Missing helper: "toJSON" logs (child request): +0 Starting rendering request 9 +12 Rendering template {shortid:HJvscWI8-, recipe:phantom-pdf,engine:handlebars} +13 Adding sample data r1BD6ZUUb +25 Replaced assets ["summary.css"] +26 Resources not defined for this template. +29 Starting rendering request 10 +31 Starting rendering request 11 +48 Starting rendering request 12 +51 Rendering template {shortid:By5KIRDhb, recipe:html,engine:handlebars} +52 Inline data specified. +55 Rendering template {shortid:HysHsW8IW, recipe:html,engine:handlebars} +55 Inline data specified. +58 Rendering template {shortid:HyMy2WI8-, recipe:html,engine:handlebars} +59 Inline data specified. +62 Resources not defined for this template. +71 Replaced assets ["summary.css"] +71 Base url not specified, skipping its injection. +71 Resources not defined for this template. +72 Base url not specified, skipping its injection. +73 Rendering engine handlebars +77 Rendering engine handlebars +106 Replaced assets ["d3.min.js","d3piechart.js"] +107 Resources not defined for this template. +111 Base url not specified, skipping its injection. +112 Rendering engine handlebars +133 Taking compiled template from engine cache +136 Replaced images [] +137 Executing recipe html +137 Skipping storing report. +137 Rendering request finished 11 +137 Rendering request 11 finished in 107 ms +178 Taking compiled template from engine cache +179 Replaced images [] +179 Executing recipe html +180 Skipping storing report. +180 Rendering request finished 10 +181 Rendering request 10 finished in 151 ms Error: Missing helper: "toJSON" at Object. (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19:13) at Object.eval (eval at createFunctionContext (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), :6:89) at main (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32) at ret (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12) at ret (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:525:21) at /usr/src/app/node_modules/jsreport-handlebars/lib/handlebarsEngine.js:25:14 at evalmachine.:1:41 at ContextifyScript.Script.runInContext (vm.js:35:29) at ContextifyScript.Script.runInNewContext (vm.js:41:15) at Object.runInNewContext (vm.js:93:38) Stak - Error: Missing helper: "toJSON" at Object. (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19:13) at Object.eval (eval at createFunctionContext (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), :6:89) at main (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32) at ret (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12) at ret (/usr/src/app/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:525:21) at /usr/src/app/node_modules/jsreport-handlebars/lib/handlebarsEngine.js:25:14 at evalmachine.:1:41 at ContextifyScript.Script.runInContext (vm.js:35:29) at ContextifyScript.Script.runInNewContext (vm.js:41:15) at Object.runInNewContext (vm.js:93:38)

    Thanks

    Paul



  • Hm. Is there any chance you would be able to click in the studio settings the Export button and email me the zip so I would be able to replicate the issue?



  • Certainly, I sent them to your hotmail address. Many thanks, Paul



  • Same issue here... Any solution? But, I'm doing it with Node.



  • @mariocsantos Please create a new topic as this is quite old and share as much information as you can. The jsreport version, stack trace, do you have authentication enabled?, jsreport export if possible. The problem described here was about shared helpers from assets not being propagated to the child requests, but I believe it was fixed some time ago.


Log in to reply
 

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