My guess is that it is something to do with the physics and CharacterBody2D specifically. Maybe I update the velocity incorrectly or something.
Anyway. Thanks for finding an interesting bug. And thanks for playing!