Fix error events need to be emitted before callbacks