Lag(?) issues

What do you mean by a time out?

The pulseIn() function takes an optional 3rd argument to define how long to wait for the transition (the return pulse). You could have looked at the documentation, you know.

If you don't limit the time to wait for a change, the default value, which is rather large, will be used. If you are only concerned about things that are close, and that's generally what a robot cares about, make the timeout just long enough for the pulse to travel the required distance and back. That way, any longer than that will not be measured, but you will know that there is nothing close.