Serious XD plugin cycle bug/design flaw

My new plugin is doing some long async extraction work under editDocument() (sometimes taking several seconds), creating and deleting text/rectangle nodes, writing files, etc., and I discovered to my surprise/horror :wink: , that XD will actually call the (panel) plugin’s update() during this process.

I.e., it’s treating the plugin as re-entrant, which it most certainly isn’t (don’t think any plugin is ready for that). React, in particular, is unhappy about this situation.

I worked around it by setting a guard bool during the editDocument(), and dismissing immediately any attempts at re-entry via update().

But I claim this is either a bad bug or a design flaw: you can’t expect a panel plugin to handle an update() when it’s in the middle of a promise-based editDocument() process.

(@kerrishotts or @peterflynn would be likely candidates to respond…)

1 Like

Or, if intended, this should at least be clearly documented :wink:

Boy, don’t know how this could be intended, since it’s asking a panel plugin to be re-entrant.

I think it’s just a bug that’s never been found before, since it only occurs once in a while with extended work being done in editDocument().

I agree (even if this might be an interesting question regarding how it could be solved differently with “external updates” in cloud documents), I’m just saying that if it is intended (or even if it isn’t, but can’t be fixed immediately), it should at least be documented :slightly_smiling_face: