jsreport / jsreport-core

The minimalist jsreport rendering core
GNU Lesser General Public License v3.0
86 stars 24 forks source link

Timeout error when debugging with protocol="inspector" #22

Closed kfrederix closed 6 years ago

kfrederix commented 6 years ago

I'm consistently getting timeout errors during render() while debugging my application using vscode with protocol "inspector".

The error is always the same:

OperationalError {
    cause: Error: Timeout error during executing script
    ...
}
at: script-manager\lib\manager-processes.js:24:8
    at ontimeout (timers.js:469:11)
    at Timer.unrefdHandle (timers.js:580:5)

Debugging with legacy protocol works without problem, but that is not supported anymore with node versions >= v8.0.

P.S. just running the application (with node v8.6.0) works fine... no problem. Only getting this error when trying to debug.

bjrmatos commented 6 years ago

hi! my first guest is that you are using the default tasks strategy (dedicated-process) which spawns a new child process for template rendering and script execution. when using child process node --inspect protocol does not work out of the box. for example if you run a node.js app with node --inspect server.js and that app spawns a child process eventually you will see a message like this in the console Starting inspector on 127.0.0.1:9229 failed: address already in use, which means that node.js fails because it is trying to use the same debug port (9229) for two processes (the main one and the child), this is the cause that makes jsreport to timeout.

captura de pantalla 2017-10-17 a las 10 01 46 a m

you have two options to solve this and let you debug your jsreport app normally:

i'm closing the issue since there is directly nothing that we can do about this (because this should be handled in user land) but if you have other comments feel free to keep the conversation. hope that this information helps you.

pofider commented 6 years ago

Hm. For me the debugging in VS Code with inspector doesn't even start. I personally don't use debugging at all when developing in node.

However the issues could be that we by default spawn child processes which are used for templating engines evaluation in sandbox. You could try to change the configuration and run templating engine directly in the same process

{
   ...
   "tasks": { "strategy": "in-process" }
   ...

or perhaps increase the timeout for templating engines using

{
   "tasks": { "timeout": 6000000 }
}
kfrederix commented 6 years ago

Thanks @bjrmatos, @pofider for such in-depth responses ! Debugging with tasks.strategy set to in-process works like a charm.

Bene-Graham commented 6 years ago

@pofider Where about do you put "tasks": { "strategy": "in-process" }?

pofider commented 6 years ago

@Bene-Graham Check readme here to see how you can pass configuration to jsreport.

Bene-Graham commented 6 years ago

@pofider Worked like a charm.

Thanks

gustavomassa commented 6 years ago

Using "tasks": { "strategy": "in-process" } doesn't work for me, same inspector error message.

pofider commented 6 years ago

in v2 it is "templatingEngines":{ "strategy": "in-process" }

gustavomassa commented 6 years ago

@pofider You are right, using templatingEngines works fine. I'm using typescript with the latest @types/jsreport-core version 1.5.1, the config interface is outdated. Also the jsreport-express options are outdated from github readme: https://github.com/jsreport/jsreport-express

This is the correct one: extensions: { express: { app: app, server: server }, }, appPath: '/api/v1/reporting' };

I think all jsreport extensions docs(Readme) should be reviewed and updated if needed.

Thanks!

bjrmatos commented 6 years ago

You are right, using templatingEngines works fine. I'm using typescript with the latest @types/jsreport-core version 1.5.1, the config interface is outdated.

@gustavomassa yes, we recently landed v2, so i guess it is matter of time for the types to be updated, we don't maintain the types as part of our release process, the current types was a collaboration of another user so hopefully another TS user can collaborate with the updates, if not we will look into it but as part of future tasks.

Also the jsreport-express options are outdated from github readme: jsreport/jsreport-express

i saw that there was just one line missing to update, it is updated now, thanks for noticing it

gustavomassa commented 6 years ago

@bjrmatos Thank you for the fast reply and resolution. As soon as I get more experience using jsreport, I can help updating the types.