If something that you were previously engaged with becomes invisible, it is likely that you would continue to to fire where you last saw it as you process the fact that it has vanished, and this logic is not lost on your opponents. While Cloak does prevent enemies from knowing where you are in order to target you, it does not in fact make you invulnerable. Therefore, the first few shots while Cloak is being activated can hit.
There are also abilities such as "Immediately Deals % Damage" or boarding abilities that currently ignore cloak, which is by design.