I see that in cursor.onerror we don't call `end`. `end` is supposed to be called when there is no error while `done` is always called, so maybe here we should not call `end` either. What do you think?

Reading how it's called and used, I don't think it's necessary to have both end and done in getThreads; it's useful in getMessages but not in getThreads. Currently, we use both but without really thinking about what's happening.

If you think the same, would you please file another bug about this?