Examples of mobs immune to them: endermen, Creative players
For arrows, they will deflect off of the immune mob indefinitely. However, tridents will make a stabbing sound, implying it actually damaged the mob in question (which it did not), and then completely ignore collision with the mob or any other mobs.
Linked issues
Attachments
Comments 6

I can confirm for 20w46a.
Can confirm in 20w51a.
Can confirm in 21w03a.
Can confirm in 21w05b.
Can confirm in 21w06a.
For information: Tridents only allow hitting an entity once, more definitely for balancing purposes, arrows, on the other hand, vanish when they hit something normally. This is likely just a side effect that I don't really think is worth the effort to fix.