Parsoid currently relies on the api=parse Mediawiki endpoint to handle extensions. This works well in most scenarios. However, if the extension is wikitext-based (ex: <gallery>), then, it can be a source of some headaches. Specifically, <ref>s in those extensions become opaque to Parsoid since they are being processed by M/W Cite.php rather than Parsoid's native Cite handler.
This shows up as bug reports like T74865, T62340, and T93580#1589644 (among others that are either unreported or will be reported).
The obvious fix is to register Parsoid-native extension handlers for those extensions that process wikitext.
There is no obvious generic fix for these. This has to be handled on a case-by-case basis for all such extensions. Specifically, writing a native <gallery> extension has been on the cards for Parsoid for a while. Something to tackle sooner than later.
I am going to leave this high-level ticket open as a tracker ticket for all such extensions.