-
Notifications
You must be signed in to change notification settings - Fork 203
Open
Labels
Description
I ran into this error while framing a large JSON-LD file:
/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:76
api.frame = (state, subjects, frame, parent, property = null) => {
^
RangeError: Maximum call stack size exceeded
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:76:13)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
at api.frame (/home/runner/work/garance/garance/node_modules/jsonld/lib/frame.js:258:15)
Seems like this is induced by some kind of recursive call in the framing algorithm, line 258 of frame.js: https://github.com/digitalbazaar/jsonld.js/blob/main/lib/frame.js#L258
I am reading here that using a "setTimeout" every e.g. 1000 recursive calls may provide the engine the chance to clear the stack: https://stackoverflow.com/a/20999077/189723
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
davidlehn commentedon Mar 6, 2025
I imagine some data patterns might have trouble there. Do you have a short example of the shape of your data and the frame? It's easier to debug these sorts of things with an example to run, and knowing the general shape of the data would help to programatically create a large test case.
tfrancart commentedon Mar 6, 2025
Thanks for your answer. I was able to track the problem down.
Here is the JSON-LD to be framed, including ~16000 instances of the class
rico:Agent
on which we apply the framing : garance-for-agents.zipHere is the frame that gives the error, on the owl:sameAs property at the bottom:
The point is that owl:sameAs can point either to external resources, or to one of the 16000 agents inside the JSON-LD. And when this is the case, the framing on these entities takes very long and crashes.
If I set
@explicit: true
in owl:sameAs (which is what I want, I want only URIs here, with labels), then the problem disappears.Here is the frame that does not gives the error (see the modified owl:sameAs at the end):
Even if I am able to work around the problem, I would be happy to understand the reason for the crash.