-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RangeError: Invalid string length on very large json dataset #291
Comments
I'm guessing that nodejs has a limit in the string length it can use. I will to reproduce your issue and see if I can think of a way to fix it (the first idea that comes to mind is to not use strings anymore when concatenating, but instead ArrayBuffers) |
Thanks for the quick response. It's very strange. I found some references that speak about it really being a memory issue. If I reduce the number of records to 2.5k it works fine but slowly.
…Sent from my iPad
On 23 Mar 2017, at 7:13 pm, Edgar Hipp <[email protected]<mailto:[email protected]>> wrote:
I'm guessing that nodejs has a limit in the string length it can use. I will to reproduce your issue and see if I can think of a way to fix it (the first idea that comes to mind is to not use strings anymore when concatenating, but instead ArrayBuffers)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#291 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABAY1OP9adH4faZJfGKUFCEqfoKWljeBks5roimngaJpZM4MmMvo>.
Steve Mcgrath
Office: (02) 9672 4222
Fax: (02) 9672 4211
[Jigsaw Technology]<http://www.jigsaw.com.au>
|
From my experiments, the max size for string is 268434896 , which is 268 MB of string length. Do you think that you exceed that length ? |
This issue in nodejs reports a very similar number : nodejs/node#10738 (comment) |
Here is the patch I applied to test this :
|
I'm closing this as we won't be able to fix it from docxtemplater code |
Environment
How to reproduce my problem :
My template is the following : template.zip
The data is of the following structure (only 1 record shown)
{ "data": [{"dru_id":"01568.1115950.00","drp_id":"0","letter_date":"23rd March, 2012","letter_date_p9d":"1st April, 2012","mail_name":"Mr X YZ & Mrs D YZ","mail_address1":"7 XXXXXX Place","mail_address2":"","mail_address3":"","mail_suburb":"SUBURBX","mail_postcode":"2000","mail_state":"NSW","mail_pafbarcode":"1301011130302012100102312123110133313","mail_pafbsp":"005","mail_pafdpid":0,"school_name_suburb":"Primary School, SuburbX","school_name":"Primary School","school_address1":"PO Box 1","school_address2":"","school_address3":"","school_state":"NSW","school_suburb":"SUBURBx","school_postcode":"2000","school_phone":"999 999","school_logo":"logox.jpg","school_main_contact":"Bill Anna","school_contact_name":"Bill Anna","contact_phone":"9999 99999","letter_signature":"Steve Anna","letter_signature_phone":"9999 99999","letter_signature_title":"Principal","bpay_code":"12345","ddf":"S2s4","ddf_crn":"99999","centrelink_crn":"XYX","overdue":832.0000,"total":2496.0000,"future":1664.0000,"deet":1568,"outstanding":832.0000,"bpay_ref":"3106 6069 7994 0","bpay_barcode":"3106 6069 7994 0","postbill_ref":"08323000000000031066069799","dd_reference":"3106606979949","ufp":370544,"first_record":true,"email":"","mobile":"","contact_method":0}], "templateName" : "Action1-ReminderStatement.docx", "hasFreeText" : false, "freeText" : "", "hasSummary" : false, "sortSummary" : [], "schoolSummary" : []}
The actual file has 7.5k records
With the following js file :
Error:
RangeError: Invalid string length
at Array.join (native)
at Object.render (C:\Program Files\iisnode\www\matthew\node_modules\docxtemplater\js\modules\loop.js:56:30)
at moduleRender (C:\Program Files\iisnode\www\matthew\node_modules\docxtemplater\js\render.js:10:28)
at C:\Program Files\iisnode\www\matthew\node_modules\docxtemplater\js\render.js:25:24
at Array.map (native)
at render (C:\Program Files\iisnode\www\matthew\node_modules\docxtemplater\js\render.js:24:26)
at XmlTemplater.render (C:\Program Files\iisnode\www\matthew\node_modules\docxtemplater\js\xml-templater.js:94:19)
at C:\Program Files\iisnode\www\matthew\node_modules\docxtemplater\js\docxtemplater.js:117:17
at Array.forEach (native)
at Docxtemplater.render (C:\Program Files\iisnode\www\matthew\node_modules\docxtemplater\js\docxtemplater.js:112:29)
Action1-ReminderStatement.zip
The text was updated successfully, but these errors were encountered: