kandashi / Active-Auras

MIT License
29 stars 36 forks source link

Undefined ID #285

Open Dyrnwyrm opened 1 year ago

Dyrnwyrm commented 1 year ago

Describe the bug Got this error on console.....

undefined aura does not exist on the embedded collection To Reproduce Steps to reproduce the behavior:

  1. Add an active aura
  2. Add the effects 3.Check if enable
  3. Canvas an console error Expected behavior Aura just applying once, not stacking

Screenshots

Captura

Environment:

Additional context The aura keeps adding itself to actors it seems like the effect is unable to delete itself, i deleted the first one but the new feature has the same issue image image

MrPrimate commented 1 year ago

Does it work with just DAE and Active Auras enabled? Can you share the details tab of the item this originates from.

mrguenther commented 3 months ago

I've found that I can reproduce this by selecting N (>=2) tokens for the same character, all of them linked to the canonical actor data, and moving them into or out of an aura. If they all enter the aura in the same motion, the module adds N copies of the ActiveEffect to the actor. If any of them leave the aura, the module tries to delete each ActiveEffect N times, causing errors on all but the first deletion attempt.

Having two tokens for the same unique character is admittedly an odd situation, but I've also found that the popular Token Attacher module makes these issues vastly more common in all sorts of situations.

Here's an example of me moving two identical tokens, both linked to the same actor data, into and back out of an aura:

FoundryVTT | 2024-07-31 03:15:56 | [info] Created ActiveEffect with id [EBS6nxNqCcbmApEs] in parent Actor [FqBWU01GjvkdzPvs]
FoundryVTT | 2024-07-31 03:15:56 | [info] Created ActiveEffect with id [lWeQa99ga1dh7ne2] in parent Actor [FqBWU01GjvkdzPvs]
FoundryVTT | 2024-07-31 03:15:57 | [info] Deleted ActiveEffect with id [EBS6nxNqCcbmApEs] in parent Actor [FqBWU01GjvkdzPvs]
FoundryVTT | 2024-07-31 03:15:57 | [error] ActiveEffect "EBS6nxNqCcbmApEs" does not exist!
Error: ActiveEffect "EBS6nxNqCcbmApEs" does not exist!
    at file:///home/mrguenther/foundryvtt/resources/app/dist/database/backend/server-backend.mjs:1:6671
    at Array.map (<anonymous>)
    at ServerDatabaseBackend._deleteDocuments (file:///home/mrguenther/foundryvtt/resources/app/dist/database/backend/server-backend.mjs:1:6641)
    at ServerDatabaseBackend.delete (file:///home/mrguenther/foundryvtt/resources/app/common/abstract/backend.mjs:174:17)
    at async Semaphore._try (file:///home/mrguenther/foundryvtt/resources/app/common/utils/semaphore.mjs:101:17)
FoundryVTT | 2024-07-31 03:15:57 | [info] Deleted ActiveEffect with id [lWeQa99ga1dh7ne2] in parent Actor [FqBWU01GjvkdzPvs]
FoundryVTT | 2024-07-31 03:15:57 | [error] ActiveEffect "lWeQa99ga1dh7ne2" does not exist!
Error: ActiveEffect "lWeQa99ga1dh7ne2" does not exist!
    at file:///home/mrguenther/foundryvtt/resources/app/dist/database/backend/server-backend.mjs:1:6671
    at Array.map (<anonymous>)
    at ServerDatabaseBackend._deleteDocuments (file:///home/mrguenther/foundryvtt/resources/app/dist/database/backend/server-backend.mjs:1:6641)
    at ServerDatabaseBackend.delete (file:///home/mrguenther/foundryvtt/resources/app/common/abstract/backend.mjs:174:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Semaphore._try (file:///home/mrguenther/foundryvtt/resources/app/common/utils/semaphore.mjs:101:17)
MrPrimate commented 3 months ago

I've found that I can reproduce this by selecting N (>=2) tokens for the same character, all of them linked to the canonical actor data, and moving them into or out of an aura. If they all enter the aura in the same motion, the module adds N copies of the ActiveEffect to the actor. If any of them leave the aura, the module tries to delete each ActiveEffect N times, causing errors on all but the first deletion attempt.

Having two tokens for the same unique character is admittedly an odd situation, but I've also found that the popular Token Attacher module makes these issues vastly more common in all sorts of situations.

Here's an example of me moving two identical tokens, both linked to the same actor data, into and back out of an aura:

FoundryVTT | 2024-07-31 03:15:56 | [info] Created ActiveEffect with id [EBS6nxNqCcbmApEs] in parent Actor [FqBWU01GjvkdzPvs]
FoundryVTT | 2024-07-31 03:15:56 | [info] Created ActiveEffect with id [lWeQa99ga1dh7ne2] in parent Actor [FqBWU01GjvkdzPvs]
FoundryVTT | 2024-07-31 03:15:57 | [info] Deleted ActiveEffect with id [EBS6nxNqCcbmApEs] in parent Actor [FqBWU01GjvkdzPvs]
FoundryVTT | 2024-07-31 03:15:57 | [error] ActiveEffect "EBS6nxNqCcbmApEs" does not exist!
Error: ActiveEffect "EBS6nxNqCcbmApEs" does not exist!
    at file:///home/mrguenther/foundryvtt/resources/app/dist/database/backend/server-backend.mjs:1:6671
    at Array.map (<anonymous>)
    at ServerDatabaseBackend._deleteDocuments (file:///home/mrguenther/foundryvtt/resources/app/dist/database/backend/server-backend.mjs:1:6641)
    at ServerDatabaseBackend.delete (file:///home/mrguenther/foundryvtt/resources/app/common/abstract/backend.mjs:174:17)
    at async Semaphore._try (file:///home/mrguenther/foundryvtt/resources/app/common/utils/semaphore.mjs:101:17)
FoundryVTT | 2024-07-31 03:15:57 | [info] Deleted ActiveEffect with id [lWeQa99ga1dh7ne2] in parent Actor [FqBWU01GjvkdzPvs]
FoundryVTT | 2024-07-31 03:15:57 | [error] ActiveEffect "lWeQa99ga1dh7ne2" does not exist!
Error: ActiveEffect "lWeQa99ga1dh7ne2" does not exist!
    at file:///home/mrguenther/foundryvtt/resources/app/dist/database/backend/server-backend.mjs:1:6671
    at Array.map (<anonymous>)
    at ServerDatabaseBackend._deleteDocuments (file:///home/mrguenther/foundryvtt/resources/app/dist/database/backend/server-backend.mjs:1:6641)
    at ServerDatabaseBackend.delete (file:///home/mrguenther/foundryvtt/resources/app/common/abstract/backend.mjs:174:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Semaphore._try (file:///home/mrguenther/foundryvtt/resources/app/common/utils/semaphore.mjs:101:17)

I don't think there is a way I can easily handle this, as each token is supposed to have its own set of actor data that it can use, which isn't the case when both tokens are linked to the same actor.

mrguenther commented 3 months ago

What about confirming that the effect with that ID hasn't already been removed before removing it (or just catching the error)? That wouldn't fix adding duplicate effects, but it would at least suppress the errors when trying to remove them.

Anyway, the bigger issue is when combined with the Token Attacher module. In that case, they don't have to be duplicate tokens linked to the same actor. I often end up with many copies of the same effect as well as dozens of error messages after I move a complex vehicle made using Token Attacher. You can reproduce the error with just two attached tokens, though. Given how popular that module is, I'd consider this to be a fairly important issue.

I'll look into it some more myself to see if I can figure out what's happening with Token Attacher.

mrguenther commented 3 months ago

It looks like the issue often happens when dragging multiple tokens through walls, such that the effect is rapidly removed and re-applied. (It might need to be multiple walls.) I think there's a race condition.

Setting "Walls Block this Aura?" to "No" seems to fix the bug, which is consistent with my theory.