setImmediate used for error emitting