OpenTermsArchive / engine

Tracks contractual documents and exposes changes to the terms of online services.
https://opentermsarchive.org
European Union Public License 1.2
105 stars 29 forks source link

Inefficient Call Stack Handling #1041

Closed jetlime closed 3 months ago

jetlime commented 6 months ago

When using the combine term with many documents relying on a filter function, the JS call stack becomes full.

For example, I combine 20 documents, with 13 of them using a filter function.

{
  "name": "--",
  "documents": {
    "--": {
      "combine": [
        {
          "fetch": "--",
          "--": "--",
          "filter": ["x"]
        },
       "--": "--",
         {
          "fetch": "--",
          "--": "--",
          "filter": ["x"]
        }]
   }  
}          

The moment, 14 of them define a filter function, I get the following error:

warn The documents cannot be accessed or their contents can not be selected:
The filter function "x" failed: RangeError: Maximum call stack size exceeded

The same issue arises when the same filter function is defined once for all documents inside the combine field.

Ndpnt commented 5 months ago

Hi @jetlime,

I haven't managed to reproduce this issue, can you give us a complete reproducible example please?

MattiSG commented 3 months ago

Lacking a reproducible case, I close this issue. Feel free to reopen with a reproducible case 😃