add error handling to buildIndex task, async write stream