Strange behaviour from on_body_exited() and the debug console

Godot Version

Godot Ver. 4.3stable

Question

` I’m seeing strange results using a rigidbody3D and on_body_exited() and would like to understand what I’m doing wrong (assuming that it isn’t a bug). The function below is as it appears in my script. In the scene is a Rigidbody3D with a capsule collider and a csg mesh with a csgcollider3d. The mesh parent node is in the “Pipe” group. Visually, the objects do collide normally and I know that the groups are working because the player state changes when moving from a “Pipe” group mesh to a “Floor” group mesh.

func _on_body_exited(body: Node) -> void:
	if body.is_in_group("Pipe"):
		print("left pipe")
		if currentState == State.airToPipe:
			print("popped")
			pop = true

Occasionally (no idea why only occasionally) this function works as intended and the pop bool is flipped to true. When this happens, “popped” is printed in the console. “left pipe” however, is not printed ever.

Is there a reason why my script is skipping this line?

Learn to use breakpoints to step through your code at runtime.

Just as an aside, there is a straight execution in those statements, if popped is printed, left pipe should always print, there is no branch, break or return.