Chapter #56. Show a "Spinner" if the Task Will Take an Indeterminate Amount of Time
In this case, by indeterminate, I mean that your software isn't sure (or has no way of knowing) how many things it has to do: it just knows that it will know when it is done.
Showing an animated spinner gives a user less information than a progress bar, but it at least tells them that something is happening and their task will be done when the spinner vanishes.
If something goes wrong, then make the spinner stop. Your user doesn't know whether this is a "loop forever" GIF, so they'll just carry on waiting when nothing is actually happening behind the scenes. Gmail shows "loading" and then, after some time, it shows "still loading", which is a nice touch.
A spinner is also great for tasks that are very short, for example a page reload, where a progress bar would be overkill.