Unloaded documents while using load() in the model SDK

0
I’m trying to get a detailed JSON structure of my app using the Mendix Model SDK. I am doing this by looping recursively through modules → folders → documents and loading these items by using .load() But this always results in random documents to not being loaded. When that happens, errors like this are thrown: UnhandledPromiseRejectionWarning: Error: This operation is not allowed on the property 'documentation' because its parent object 'JavaActions$JavaAction' with ID '001664f4-246c-4ccd-a76b-d32d0544f558' was not fully loaded. Load the property's parent object with the '.load(callback)' command. For example: This error was thrown by trying to load a PageTemplate document in my app with no visible connection to the Java action in the error (StartTransaction – CommunityCommons) Is there a way to check if a document needs other documents to be loaded before it loads itself? I’ve tried to load all documents before running the recursive method, but that also results in the same errors.
asked
1 answers
1

I’ve found the solution

These errors were thrown because some parts of the code weren’t running asynchronously. So be sure to check

  1. whether all functions are await, and not .then()
  2. whether all for loops are for(let item of items) {} and not list.forEach(item => {})
  3. other async/callback calls that might be causing async problems
answered