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.
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.