Hi @jan_blaha , Thanks a lot for your recommendations, finally I found the crashes module, that used a postgres without installing it
on this server. You save my life!!! I've completely confused
Thanks again
Posts made by alishokoie
-
RE: jsreport beforeRender problem with Error: Unable to find module foo
-
RE: jsreport beforeRender problem with Error: Unable to find module foo
Hi @jan_blaha , i tried everything that I've known and now I've confused. Are you recommend me to reinstalling jsreport from scratch?
I think probably there was a mistake in installing or configuring jsreport! -
RE: jsreport beforeRender problem with Error: Unable to find module foo
Hi @jan_blaha and thank you for help. I've removed index.js from foo directory, so there is no relation to my custom code
and tried to test again, but the error is still and is as expected "Unable to find module foo".
It seems as i commented in "berforeRender", that error occurred in second line of code:var ds = require('foo');
and none of my script does not executed. Thus can I explain why after removing index.js
there is no difference in error in both cases. I think actually jsreport can not find foo. In addition
the error log that i included in first post shows thatsearch path: foo foo /opt/jsreport/foo ....
jsreport searches foo in /opt/jsreport directory that is false, it must be /opt/jsreport/node_modules.
Is it correct? Have I understand correctly?regards
-
RE: jsreport beforeRender problem with Error: Unable to find module foo
Hi @jan_blaha again, a point that i remembered now is my code works fine on another server and the only difference is
that node version there is v4.4.7 but here it is v8.14.1 , although I have installed foo with npm install .. that make the dependencies
up to date . Jsreport version is "jsreport 1.4.0 production" on both servers.
Can this difference be the source of error? although as i mentioned in last posts the script executes on this machine without error!!!! -
RE: jsreport beforeRender problem with Error: Unable to find module foo
Hi @jan_blaha , in conjunction with your suggestion about "foo", i tried to test some simple code instead of "couchbase-ds.js".
Unfortunately the result is not changed and i see the same error again: "Unable to find module foo".here is the sample code in :
couchbase-ds.jsvar CouchbaseDS = exports.CouchbaseDS = function(context) { this.bucket = null; } CouchbaseDS.prototype.open = function(bucket_name, cb) { return cb && cb(null); } CouchbaseDS.prototype.queryLog = function(key, cb) { var now = new Date(); var al = { days: [], queue: { name: key.queue, reportDate: formatDate(now.valueOf()), startDate: key.interval_start != undefined ? formatDate(key.interval_start) : '', endDate: key.interval_end != null ? formatDate(key.interval_end) : '' } }; return cb && cb(null, al); } CouchbaseDS.prototype.queryBriefActivityLog = function(key, cb) { var now = new Date(); var al = { days: [], entity: { name: key.queue ? key.queue : key.user[0], reportDate: formatDate(now.valueOf()), startDate: key.interval_start != undefined ? formatDate(key.interval_start) : '', endDate: key.interval_end != null ? formatDate(key.interval_end) : '' } }; return cb && cb(null, al); } function formatDate(x) { var d = new Date(x); return [ d.getFullYear(), d.getMonth()+1, d.getDate() ].join('/') + ' ' + [ d.getHours(), d.getMinutes(), d.getSeconds() ].join(':'); }
Therefore i think that the error is not depends on scripts. Are you agree? What can I check?
Thanks in advanced. -
RE: jsreport beforeRender problem with Error: Unable to find module foo
Hi @jan_blaha , "foo" is a directory that contain some custom scripts and package.json .
here is my directory structure:/opt
/jsreport
/node_modules
/foo
index.js
package.json
/node_modules
/lib
couchbase-ds.js
surveyReport.jsand package.json is as follows:
{ "name": "foo", "main": "index.js", "dependencies": { "couchbase": ">= 2.0.7", "esl": ">= 3.0.0", "hiredis": ">= 0.3.0", "modesl": ">= 1.1.3", "mysql": ">= 2.6.2", "redis": ">= 0.12.1", "ssh2": ">= 0.4.13", "utf8": "^2.1.1" } }
and index.js is here:
var ods = module.exports = {} ods.CouchbaseDS = require("./lib/couchbase-ds.js").CouchbaseDS; ods.SurveyReport = require("./lib/surveyReport.js").SurveyReport;
It's important that main script in surveyReport.js executes without any error and returns desired data structure,
when i run it as test script on the same machine. also it seems that there isn't any faulty code in it. -
RE: jsreport beforeRender problem with Error: Unable to find module foo
As I included error in first message, "foo" folder placed at /opt/jsreport/node_modules but it seems that jsreport searches it in /opt/jsreport folder and I don't know why!
Although I know (if I correctly understand) require searches in current directory and then ./node_modules . if is it correct, why jsreport can not find "foo"?Is there any configuration item for this search. For test I got the __rootDirectory and __appDirectory global variable and logged them and both of them are pointed to /opt/jsreport. Is it correct?
-
RE: jsreport beforeRender problem with Error: Unable to find module foo
Hi @MI53RE19 , thank you for your attention. Yes, I took care about allowedModules .
here is this part of prod.config.json:
"scripts": {
"allowedModules": ["handlebars", "request-json", "feedparser", "request", "underscore",
"constants", "sendgrid", "console", "foo"],
"timeout": 120000
},but the Error still.
regards -
jsreport beforeRender problem with Error: Unable to find module foo
Hi All,
At the beginning of beforeRender function, when i require a script folder, it fails with the error
"Error: Unable to find module foo" . This folder place at /opt/jsreport/node_modules folder and contains some scripts, package.json, index.js as main in package.json, and node_modules folder with package dependencies.function beforeRender(done) { var console = require('console'); // Error happens at following line of code var ods = require('foo'); var ds = new ods.CouchbaseDS(); var options = request.options.parameters; var recipe = request.options.recipe; console.log(request.options); ds.open(function(err) { if (err) { console.log('Error on opening logdb', err); return done(); } var ts = options.hasOwnProperty('time_scale') && options.time_scale !== '' ? options.time_scale : 1; ds.queryLog({ queue: options.queue, interval_start: options.start_date.valueOf(), interval_end: options.stop_date.valueOf(), time_scale: ts }, function(err, result) { if(err) console.log(err); else { result.queue.recipe = recipe; request.data = result; done(); } }); }); }
Error context is as follows:
Error occured - Error during rendering report: Unable to find module foo Searched paths: foo foo /opt/jsreport/foo /opt/jsreport/foo /opt/jsreport/foo Stak - /opt/jsreport/node_modules/jsreport-scripts/lib/scriptEvalChild.js:25 throw new Error('Unable to find module ' + moduleName + os.EOL + 'Searched paths: ' + os.EOL + searchedPaths) ^ Error: Unable to find module foo Searched paths: foo foo /opt/jsreport/foo /opt/jsreport/foo /opt/jsreport/foo at doRequire (/opt/jsreport/node_modules/jsreport-scripts/lib/scriptEvalChild.js:25:13) at _require (/opt/jsreport/node_modules/jsreport-scripts/lib/scriptEvalChild.js:41:14) at beforeRender (evalmachine.<anonymous>:3:13) at evalmachine.<anonymous>:71:111 at ContextifyScript.Script.runInContext (vm.js:59:29) at ContextifyScript.Script.runInNewContext (vm.js:65:15) at Object.runInNewContext (vm.js:135:38) at module.exports (/opt/jsreport/node_modules/jsreport-scripts/lib/scriptEvalChild.js:123:6) at process.<anonymous> (/opt/jsreport/node_modules/script-manager/lib/worker-processes.js:45:38) at emitTwo (events.js:126:13)
Any Ideas?
can you tell me some tips so that i solve my problem.
Thanks! -
RE: How can make report faster during rendering?
Hi Oshri,
unfortunately not, I think my problem needs to deep considerations, and temporary I've disabled some reports, because could not wait for a suitable solution.
But I must come back to the issue as soon as possible and I share the results. -
Special access right
Hi there,
Can I define a user that has right to define permission for users and only read permission for accessing to scripts and templates? -
RE: How can make report faster during rendering?
Thanks a lot Jan for your reply. I will be make the changes and then monitor it, that can find only this issue is my problem
-
How can make report faster during rendering?
Hi, I have a virtual server running jsreport with a lot of Memory and 16 core CPUs and
more than 10 reports on it and everything works fine, except that 90% of users (that are about 30-40 users) working with only one report at the time. As I monitored, data retrieving and manipulating for report take about 100 ms but rendering takes between 10 to 16 seconds, other hand I see that only 3 or 4 core CPUs use proccessing time and others are idle. I think this is depends on "tasks.numberOfWorkers" config, that in my configuration file is 4. Now the question so I understand is can with exceeding this parameter make all CPUs active in the rendering process?Thanks