This issue has been created
There is 1 update.
 
 
Unified Documents Application / cid:jira-generated-image-avatar-d08fed72-0097-4e35-ac0b-d5e0ff7cf5cf UDA-14 Open

Sections tree randomly fails to load: "Uncaught TypeError: b(...).xtree is not a function" (timing race loading the tree WebJAR)

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-37b320e7-cdde-4079-805d-0dae17c3204a Josué Tille created this issue on 20/Oct/26 17:54
 
Summary: Sections tree randomly fails to load: "Uncaught TypeError: b(...).xtree is not a function" (timing race loading the tree WebJAR)
Issue Type: cid:jira-generated-image-avatar-d08fed72-0097-4e35-ac0b-d5e0ff7cf5cf Bug
Affects Versions: 1.2.7
Assignee: Unassigned
Created: 20/Oct/26 17:54
Priority: cid:jira-generated-image-static-major-cb44a72a-0a30-4093-ba32-4706e9bca10f Major
Reporter: Josué Tille
Description:

Context

UDA-12 (fixed in 1.2.7) changed how the sections tree of UnifiedDocumentSectionDisplayer loads the tree WebJAR: it registers a RequireJS alias xtree through require.config and points it to require-config.min.js of
xwiki-platform-tree-webjar.

Problem

require-config.min.js is a Velocity template that only publishes RequireJS paths as a side effect of require.config(). It defines {}no AMD module{} and does not set $.fn.xtree. RequireJS therefore treats it as a "plain
script": the xtree module resolves as soon as that file is loaded, with an undefined export. The callback of:

                                                                                                                                                                                                                        
   require(['jquery', 'xtree', 'xwiki-selectize'], function($) { ... })                                                                                                                                                                     
   

can then run while tree.min.js (the real module defining $.fn.xtree) is still being downloaded, which randomly breaks the sections tree with:

                                                                                                                                                                                                                               
   Uncaught TypeError: b(...).xtree is not a function                                                                                                                                                                                       
   

This is a pure timing issue: setting a breakpoint (slowing down execution) makes the error disappear. It also only seemed to work on some XWiki versions because the platform's own tree widget (e.g. the breadcrumb) happened to load
tree.min.js concurrently, before the application code.

Steps to reproduce

  1. Install Unified Documents Application 1.2.7 on a recent XWiki (17.10+)
  2. Open the sections tree of a unified document (view or edit)
  3. The tree randomly fails to render, the browser console reports Uncaught TypeError: b(...).xtree is not a function

Proposed fix

Require the standard xwiki-tree module published globally by the Flamingo skin since XWiki 15.10:

                                                                                                                                                                                                                        
   require(['jquery', 'xwiki-tree', 'xwiki-selectize'], function($) { ... });                                                                                                                                                               
   

Since it is the real AMD module of the WebJAR (tree.min.js), AMD guarantees that $.fn.xtree is defined before the callback runs — the race is gone.

This required bumping the application's parent-platform to 15.10.

 
 

1 update

 
cid:jira-generated-image-avatar-37b320e7-cdde-4079-805d-0dae17c3204a Changes by Josué Tille on 20/Oct/26 17:54
 
Assignee: Josué Tille