Hi and thx for the module jsreport, it's very useful
We rely on jsreport in production heavily and we often stumble on this error :
2021-07-02T12:11:20+02:00 [] ERROR (4057 on a6982745-09a5-490c-99b7-29ef5a93a707): Fri, 02 Jul 2021 10:11:16 GMT: exception lors de la génération du rapport: Invalid string length, stack: RangeError: Invalid string length
2021-07-02T12:11:20+02:00 at JSON.stringify (<anonymous>)
2021-07-02T12:11:20+02:00 at Object.module.exports.serialize (/home/bas/app_4f808f19-b484-4ae7-9953-f6fe11b6bc05/node_modules/serializator/index.js:23:14)
2021-07-02T12:11:20+02:00 at module.exports.ScriptsManager.execute (/home/bas/app_4f808f19-b484-4ae7-9953-f6fe11b6bc05/node_modules/script-manager/lib/manager-processes.js:85:30)
2021-07-02T12:11:20+02:00 at module.exports.tryCatcher (/home/bas/app_4f808f19-b484-4ae7-9953-f6fe11b6bc05/node_modules/jsreport-core/node_modules/bluebird/js/release/util.js:16:23)
2021-07-02T12:11:20+02:00 at module.exports.ret [as executeAsync] (eval at makeNodePromisifiedEval (/home/bas/app_4f808f19-b484-4ae7-9953-f6fe11b6bc05/node_modules/jsreport-core/node_modules/bluebird/js/release/promisify.js:1:1), <anonymous>:13:39)
2021-07-02T12:11:20+02:00 at executeScript (/home/bas/app_4f808f19-b484-4ae7-9953-f6fe11b6bc05/node_modules/jsreport-core/lib/util/executeScript.js:41:49)
2021-07-02T12:11:20+02:00 at Reporter.executeScript (/home/bas/app_4f808f19-b484-4ae7-9953-f6fe11b6bc05/node_modules/jsreport-core/lib/reporter.js:343:12)
2021-07-02T12:11:20+02:00 at invokeRender (/home/bas/app_4f808f19-b484-4ae7-9953-f6fe11b6bc05/node_modules/jsreport-core/lib/render/render.js:60:36)
2021-07-02T12:11:20+02:00 at module.exports (/home/bas/app_4f808f19-b484-4ae7-9953-f6fe11b6bc05/node_modules/jsreport-core/lib/render/render.js:150:11)
which originates from
|
module.exports.serialize = (obj, { prettify = false, prettifySpace = 2 } = {}) => { |
which is caused by a huge amont of data to render, which probably exceed the maximum length allowed in nodejs (which itself is limited by V8, presumably here
https://github.com/nodejs/node/blob/eb24573987b27ad516b5bc86bfb320660540e2bf/deps/v8/include/v8.h#L3004-L3007)
Consequences :
- jsreport crashes obviously
- prototype methods are not restored, means than monkey paths remains forever 😞
How do you think things could be improved ?
Of course we have tried to change business logic, to reduce the size of the data being rendered, but we have reached a limit now.
Do you think it could be possible to stringify by chunks ?
eg semthing like https://dev.to/madhunimmo/json-stringify-rangeerror-invalid-string-length-3977 ?
Also try/catch line 29 to be sure to restore prototype method in all cases ?
Thx by advance for your ideas
Hi and thx for the module jsreport, it's very useful
We rely on jsreport in production heavily and we often stumble on this error :
which originates from
serializator/index.js
Line 8 in 8344812
which is caused by a huge amont of data to render, which probably exceed the maximum length allowed in nodejs (which itself is limited by V8, presumably here https://github.com/nodejs/node/blob/eb24573987b27ad516b5bc86bfb320660540e2bf/deps/v8/include/v8.h#L3004-L3007)
Consequences :
How do you think things could be improved ?
Of course we have tried to change business logic, to reduce the size of the data being rendered, but we have reached a limit now.
Do you think it could be possible to stringify by chunks ?
eg semthing like https://dev.to/madhunimmo/json-stringify-rangeerror-invalid-string-length-3977 ?
Also try/catch line 29 to be sure to restore prototype method in all cases ?
Thx by advance for your ideas