I have sent a request for this issue last month, but my example was too complex. 
Here is the simplest example I could get that reproduces the issue. This seems to be a problem with updating restqx functions, so I'm unsure how to reproduce it with a .bsx.
If you use the attached db with the attached query on localhost:8984. The browser should freeze on BaseXMas when accessing debug/debug-freeze. 
- The xslt works. If you make the function none updating and return $result. You'll see the video.png in the browser.
 
- The updating function works. If you replace the node $result with <hey/> and comment out the xslt:transform line. The document will be replace in the db.
 - The two don't work together.
 
Specific characteristic if this xsl:
- It uses a rest access to extract the path for the video. Without the doc('http://...rest…') line, this would work. 
 
Note that this used to work with prior versions of BaseX. 
Thanks,
France
-- 
France Baril
Architecte documentaire / Documentation architect
france.baril@architextus.com
(514) 572-0341