Hey Everyone, I am using JSreport for production and it is deployed in Heroku with 1x dyno
But app keep crashing when 11 concurrent requests are made. I am unable to figure out what is the root issue
I am using the default jsreport.config.json
{
"extensions": {
"httpPort": 5488,
"httpsPort": null,
"store": {
"provider": "fs"
},
"blobStorage": {
"provider": "fs"
},
"logger": {
"console": {
"transport": "console",
"level": "debug"
},
"file": {
"transport": "file",
"level": "info",
"filename": "logs/reporter.log"
},
"error": {
"transport": "file",
"level": "error",
"filename": "logs/error.log"
}
},
"allowLocalFilesAccess": true,
"templatingEngines": {
"timeout": 10000,
"numberOfWorkers": 12,
"strategy": "http-server",
"templateCache": {
"max": 100,
"enabled": true
}
},
"chrome": {
"timeout": 40000,
"strategy": "chrome-pool",
"numberOfWorkers": 12,
"launchOptions": {
"args": [
"--no-sandbox"
]
}
}
}
hi @gauravprwl14
hmm the configuration file looks wrong, it should be more like this:
{
"httpPort": 5488,
"httpsPort": null,
"store": {
"provider": "fs"
},
"blobStorage": {
"provider": "fs"
},
"logger": {
"console": {
"transport": "console",
"level": "debug"
},
"file": {
"transport": "file",
"level": "info",
"filename": "logs/reporter.log"
},
"error": {
"transport": "file",
"level": "error",
"filename": "logs/error.log"
}
},
"allowLocalFilesAccess": true,
"templatingEngines": {
"timeout": 10000,
"numberOfWorkers": 12,
"strategy": "http-server",
"templateCache": {
"max": 100,
"enabled": true
}
},
"extensions": {
"chrome": {
"timeout": 40000,
"strategy": "chrome-pool",
"numberOfWorkers": 12,
"launchOptions": {
"args": [
"--no-sandbox"
]
}
}
}
}
however i don’t know if this is the real file you are using or you just copied it wrong here
as per the 11 concurrent requests problem hmm i don’t have a good explanation, it will be really weird the jsreport produces this alone, i guess this is a problem with some configuration in Heroku, are there no logs available in the Heroku side?
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.387Z - debug: Base url not specified, skipping its injection.
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.403Z - debug: Replaced assets ["Helvetica.otf"]
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.405Z - debug: Rendering engine handlebars
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.414Z - debug: Replaced assets ["Helvetica.otf"]
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.417Z - debug: Rendering engine handlebars
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.429Z - debug: Replaced assets ["Helvetica.otf"]
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.430Z - debug: Rendering engine handlebars
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.565Z - debug: Compiled template not found in the cache, compiling
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.570Z - debug: Executing recipe chrome-pdf
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.699Z - debug: Compiled template not found in the cache, compiling
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.708Z - debug: Compiled template not found in the cache, compiling
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.711Z - debug: Compiled template not found in the cache, compiling
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.724Z - debug: Compiled template not found in the cache, compiling
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.794Z - debug: Compiled template not found in the cache, compiling
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.796Z - debug: Compiled template not found in the cache, compiling
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.797Z - debug: Executing recipe chrome-pdf
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.798Z - debug: Executing recipe chrome-pdf
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.798Z - debug: Executing recipe chrome-pdf
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.800Z - debug: Compiled template not found in the cache, compiling
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.803Z - debug: Executing recipe chrome-pdf
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.806Z - debug: Executing recipe chrome-pdf
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.807Z - debug: Executing recipe chrome-pdf
May 25 04:01:10 airops-reporting-staging app/web.1 2020-05-25T11:01:10.809Z - debug: Executing recipe chrome-pdf
May 25 04:01:11 airops-reporting-staging app/web.1 2020-05-25T11:01:11.202Z - debug: Converting with chrome HeadlessChrome/79.0.3945.0 using chrome-pool strategy
May 25 04:01:11 airops-reporting-staging app/web.1 2020-05-25T11:01:11.430Z - debug: Converting with chrome HeadlessChrome/79.0.3945.0 using chrome-pool strategy
May 25 04:01:11 airops-reporting-staging app/web.1 2020-05-25T11:01:11.486Z - debug: Converting with chrome HeadlessChrome/79.0.3945.0 using chrome-pool strategy
May 25 04:01:14 airops-reporting-staging app/web.1 #1 0x55e7300d3ee3 base::debug::StackTrace::StackTrace()
May 25 04:01:14 airops-reporting-staging app/web.1 #3 0x55e73014225f base::SimpleThread::Start()
May 25 04:01:14 airops-reporting-staging app/web.1 #4 0x55e72e910a72 content::SandboxHostLinux::Init()
May 25 04:01:14 airops-reporting-staging app/web.1 #8 0x55e72fd5a9dd headless::(anonymous namespace)::RunContentMain()
May 25 04:01:14 airops-reporting-staging app/web.1 #9 0x55e72fd5a73b headless::HeadlessShellMain()
May 25 04:01:14 airops-reporting-staging app/web.1 #12 0x55e72da1f0aa _start
May 25 04:01:14 airops-reporting-staging app/web.1 #0 0x55e73016fe29 base::debug::CollectStackTrace()
May 25 04:01:14 airops-reporting-staging app/web.1 #1 0x55e7300d3ee3
});
Engine.Handlebars
for the header merge operation
the string is
function getPageNumber (pageIndex) {
if (pageIndex == null) {
return ''
}
const pageNumber = pageIndex + 1
return pageNumber
}
function getTotalPages (pages) {
if (!pages) {
return ''
}
return pages.length
}
Hi... I am trying to access the $pdf object in my handlebars template so that I can write conditional logic for the PDF header based on the pageNumber..... but I am unable to manage to get the $pdf variable working... it probably seems to stay undefined... I tried different ways but I am not able to make it work... PLEASE SOMEONE KINDLY HELP ME..
more info: using jsreport-core https://github.com/jsreport/jsreport-core in nodejs
I'm back! I was able to reproduce this using the toc template. Using 2.10.0 you'll notice that the page numbers don't display on the toc. If you run this using 2.6.0 and 1.5.1 pdf-utils, they display fine.
string strDocx = _env.WebRootPath + "\\reports\\CV.docx";
FileInfo fileInfoMain = new FileInfo(strDocx);
if (fileInfoMain.Exists)
{
FileStream fileStream = fileInfoMain.Open(FileMode.Open, FileAccess.Read);
using StreamReader reader = new StreamReader(fileStream);
strDocx = await reader.ReadToEndAsync().ConfigureAwait(true);
await fileStream.DisposeAsync().ConfigureAwait(true);
}
strDocx = strDocx.Replace(Environment.NewLine, string.Empty, StringComparison.InvariantCulture);
Asset myAsset = new jsreport.Types.Asset();
myAsset.Content = strDocx;
jsreport.Types.Report report = await _jsReportMvcService.RenderAsync(new RenderRequest()
{
Template = new Template
{
Engine = Engine.Handlebars,
Recipe = Recipe.Docx,
Docx = new Docx {
TemplateAsset = myAsset
}
},
Data = null
})
.ConfigureAwait(true);
string strDocx = _env.WebRootPath + "\\reports\\CV.docx";
FileInfo fileInfoMain = new FileInfo(strDocx);
if (fileInfoMain.Exists)
{
FileStream fileStream = fileInfoMain.Open(FileMode.Open, FileAccess.Read);
using StreamReader reader = new StreamReader(fileStream);
strDocx = await reader.ReadToEndAsync().ConfigureAwait(true);
await fileStream.DisposeAsync().ConfigureAwait(true);
}
byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(strDocx);
string strDocTemplate = Convert.ToBase64String(plainTextBytes);
jsreport.Types.Report report = await _jsReportMvcService.RenderAsync(new RenderRequest()
{
Template = new Template
{
Engine = Engine.Handlebars,
Recipe = Recipe.Docx,
Docx = new Docx
{
TemplateAsset = new Asset
{
Encoding = "base64",
Content = strDocTemplate
}
}
},
Data = new
{
message = "Hello world"
}
})
.ConfigureAwait(true);