Add damage type, "bypasses_cooldown" or "bypasses_cooldown and no_knockback".
These two commands can cause this bug.
damage A 1 [bypasses_cooldown]
damage A 1 [bypasses_cooldown, no_knockback] by B
This bug is not happened by projectile attacks such as bows and tridents.
I'm not sure what the bug is here. Please can you add a description on how to reproduce this and further clarification on what the bug is?
Please also test to see if it happens in the latest release and snapshot.