highsource / jsonix

Powerful XML<->JSON JavaScript mapping library.
BSD 2-Clause "Simplified" License
356 stars 75 forks source link

[Node v10.15.0 64-bit] Calling Jsonix.Context([...]) results in "Uncaught RangeError: Maximum call stack size exceeded" #221

Open jabez007 opened 5 years ago

jabez007 commented 5 years ago

Jsonix_Files.zip

I am attempting to create a node.js client for a vendor's API. I used the Jsonix Schema Compiler to generate the JavaScript file for creditcard_loan, and I can run that just fine in my unit tests. When I run my unit tests for personal_loan though I get

RangeError: Maximum call stack size exceeded
    at Class.build (C:\Users\jwmccann\source\repos\loanspq\node_modules\jsonix\jsonix.js:2232:20)
    at Class.build (C:\Users\jwmccann\source\repos\loanspq\node_modules\jsonix\jsonix.js:2236:25)
...
at Class.build (C:\Users\jwmccann\source\repos\loanspq\node_modules\jsonix\jsonix.js:2236:25)
    at Class.buildTypeInfos (C:\Users\jwmccann\source\repos\loanspq\node_modules\jsonix\jsonix.js:3993:13)
    at Class.processModules (C:\Users\jwmccann\source\repos\loanspq\node_modules\jsonix\jsonix.js:5921:13)
    at Class.initialize (C:\Users\jwmccann\source\repos\loanspq\node_modules\jsonix\jsonix.js:5889:10)
    at new Class (C:\Users\jwmccann\source\repos\loanspq\node_modules\jsonix\jsonix.js:44:19)

I found issue #114 and tried to follow the guidance of using a bindings file, but didn't get any where. From what seemed to be the root cause of issue #114 I looked through the generated JavaScript for personal_loan and found that the DECLARATIONS under PERSONALBASEAPPLICANT may be the issue. So I tried commenting out the DECLARATIONS element from the personal_loan.xsd, regenerated the JavaScript, and my unit tests started passing. When I compared this DECLARATIONS to the creaditcard_loan I found that the creditcard_loan appears to have the same structure as personal_loan, so I am struggling to why the creditcard_loan works, but the personal_loan does not.

Is there anything here that you can help with? Or any more information you might need to be able to help?

jabez007 commented 5 years ago

Also, I found that it seems to be specific to the SPOUSE of the APPLICANT on the personal_loan. If I comment out the DECLARATIONS element under PERSONALBASEAPPLICANT or the SPOUSE element (which is a PERSONALBASEAPPLICANT) under APPLICANT I can get my unit tests to pass for personal_loan

jabez007 commented 5 years ago

Some how, adding this complexType to the original personal_loan XSD (and changing absolutely nothing else) allows my unit tests to pass

  <xs:complexType name="aslkdfjhakjnviasdth">
    <xs:complexContent mixed="false">
      <xs:extension base="BASE_APPLICANT">

      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

and the XML document deserializes correctly as far as I can tell.

highsource commented 5 years ago

Please send me a PR with a reproducing test project here:

https://github.com/highsource/jsonix-support/tree/master/l/lpq

Ideally you'd provide a generating script and some kind of a test case. Here's an exemplary test project:

https://github.com/highsource/jsonix-support/tree/master/r/reqif

Then I will look into it.

Apparently there's some kind of an infinite cycle, but I can't tell what's causing it exactly.