I have a indicator for where a throwable object lands, which rotates to align with the normal of the surface. Though, randomly the mesh instance will disappear after changing its transform, never to be seen again. This is strange because sometimes it works and sometimes it doesn't, so the issue has been really tough to diagnose.

Here's the code, funny thing is whenever I comment out the line that sets the Indicator's (which is a mesh 3d) transform the indicator never disappears.
func update_trajectory(dir: Vector3, delta):
var max_points = 300
var pos = get_parent().global_position
var vel = (dir * throw_lateral_velocity) + Vector3(0, throw_veritcal_velocity, 0)
for i in max_points:
var start_point = pos
vel.y -= gravity * delta
pos += vel * delta
var result = raycast_query(start_point, pos)
if result != null:
pos = result["position"]
%Indicator.global_position = result["position"]
%Indicator.global_transform = align_with_y(%Indicator.global_transform, result["normal"])
print(%Indicator.global_transform)
break
LineRenderer.draw_line(start_point, pos, Color.AQUA)
func align_with_y(xform: Transform3D, new_y: Vector3):
xform.basis.y = new_y
xform.basis.x = -xform.basis.z.cross(new_y)
xform.basis = xform.basis.orthonormalized()
return xform