# Serious XD plugin cycle bug/design flaw

**URL:** <https://forums.creativeclouddeveloper.com/t/serious-xd-plugin-cycle-bug-design-flaw/1887>\
**Category:** UXP Plugin API\
**Tags:** api-feedback\
**Created:** [July 1, 2020, 2:13pm UTC](https://forums.creativeclouddeveloper.com/t/serious-xd-plugin-cycle-bug-design-flaw/1887 "2020-07-01T14:13:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpryland](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/cpryland/32/1172_2.png) [@cpryland](https://forums.creativeclouddeveloper.com/u/cpryland)\
**Post date:** [July 1, 2020, 2:13pm UTC](https://forums.creativeclouddeveloper.com/t/serious-xd-plugin-cycle-bug-design-flaw/1887/1 "2020-07-01T14:13:03Z")

</div>

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 😉 , 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…)

---

<div class="post-metadata">

**Author:** ![pklaschka](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pklaschka/32/3162_2.png) [@pklaschka](https://forums.creativeclouddeveloper.com/u/pklaschka)\
**Post date:** [July 1, 2020, 4:26pm UTC](https://forums.creativeclouddeveloper.com/t/serious-xd-plugin-cycle-bug-design-flaw/1887/2 "2020-07-01T16:26:13Z")

</div>

Or, if intended, this should at least be clearly documented 😉

---

<div class="post-metadata">

**Author:** ![cpryland](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/cpryland/32/1172_2.png) [@cpryland](https://forums.creativeclouddeveloper.com/u/cpryland)\
**Post date:** [July 1, 2020, 4:28pm UTC](https://forums.creativeclouddeveloper.com/t/serious-xd-plugin-cycle-bug-design-flaw/1887/3 "2020-07-01T16:28:12Z")

</div>

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()`.

---

<div class="post-metadata">

**Author:** ![pklaschka](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pklaschka/32/3162_2.png) [@pklaschka](https://forums.creativeclouddeveloper.com/u/pklaschka)\
**Post date:** [July 1, 2020, 4:56pm UTC](https://forums.creativeclouddeveloper.com/t/serious-xd-plugin-cycle-bug-design-flaw/1887/4 "2020-07-01T16:56:48Z")

</div>

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 🙂
