Fixed a bug in fetching task state.