chrisk123999 / chris-premades

MIT License
46 stars 53 forks source link

[BUG] Error messages in skill roll messages when multiple rolls are made by different players at the same time. #327

Closed joaquinpereyra98 closed 3 weeks ago

joaquinpereyra98 commented 3 weeks ago

Foundry

System:

The world has been created for the purpose of replicating the bug.

Modules Installed:

  1. Cauldron of Plentiful Resources - 1.0.39
  2. ​Dynamic effects using Active Effects (DAE) - 11.3.65
  3. libWrapper - 1.13.2.0
  4. ​Midi QOL - 11.6.25.1
  5. ​Sequencer - 3.4.3
  6. socketlib - 1.1.0
  7. Times Up - 11.3.19

How to replicate it

Execute a macro script with the following code:

const actor= await fromUuid("uuid of a actor1");
const actor2 = await fromUuid("uuid of actor 2");
actor.rollSkill("ath")
actor2.rollSkill("ath")

img-2024-11-05-21-03-37

Note: if a timeout of one millisecond is added between rolls, the bug does not occur.

const actor= await fromUuid("uuid of a actor1");
const actor2 = await fromUuid("uuid of actor 2");
actor.rollSkill("ath")
await new Promise(r => setTimeout(r, 1));
actor2.rollSkill("ath")

imagen

Autumn225 commented 3 weeks ago

Sorry, what part does CPR play in this? You didn't include any details of how this is CPR related. And is rollSkill an async function?

chrisk123999 commented 3 weeks ago

Is there a console error?

joaquinpereyra98 commented 3 weeks ago

Sorry, what part does CPR play in this? You didn't include any details of how this is CPR related. And is rollSkill an async function?

the bug only happens if CPR is activated in the world rollSkill is async

chrisk123999 commented 3 weeks ago

What's the bug?

Autumn225 commented 3 weeks ago

And what happens if you await the roll skill?

joaquinpereyra98 commented 3 weeks ago

Is there a console error?

there is no error in the console

What's the bug?

When skill rolls are made for different actors in the chat they appear as if they belong to the same actor. Note: the modifiers seem to be correct, the error is only at the moment of creating the message.

And what happens if you await the roll skill?

the bug does not appear

Autumn225 commented 3 weeks ago

I don't think it counts as a bug if you're using a function not as intended. If it works fine when it's properly awaited, I see no issue. Yes it's probably caused by the extra millisecond of code it goes through when CPR patches the function, but I don't think there's anything CPR can do about that.

roth-michael commented 3 weeks ago

(I do still plan to look into it, in case for whatever reason those rolls are forced to happen in a sync context - though I do think not awaiting them is likely to result in unexpected behavior)

roth-michael commented 3 weeks ago

Will wait to close until the next release is out and you can verify it works with your code, but feeling confident that I squashed it.