diff --git a/lib/mirage.js b/lib/mirage.js index add3dc9..62c3758 100644 --- a/lib/mirage.js +++ b/lib/mirage.js @@ -277,22 +277,14 @@ Mirage.prototype.__doPostStream = function( // special non-user level events. if (eventBlock === "system") { if (dataPart === STREAM_START_TAG) { - // Process at next event loop tick, as the 'start' event \ - // might come out-of-order. - setImmediate(function() { - // Raise 'start' event - emitter.emit("start"); - }); + // Raise 'start' event + emitter.emit("start"); } else if (dataPart === STREAM_DONE_TAG) { // Clear previous stall timeout (as needed) fnCancelNextChunkStall(); - // Process at next event loop tick, as the 'done' event \ - // might come out-of-order. - setImmediate(function() { - // Raise 'done' event - emitter.emit("done"); - }); + // Raise 'done' event + emitter.emit("done"); } } else { var dataPartObject = JSON.parse(dataPart); @@ -306,12 +298,8 @@ Mirage.prototype.__doPostStream = function( eventName = (":" + eventName); } - // Process at next event loop tick, as the 'data' event might \ - // come out-of-order. - setImmediate(function() { - // Raise event (fallback to 'data' if no event block) - emitter.emit(eventName, dataPartObject); - }); + // Raise event (fallback to 'data' if no event block) + emitter.emit(eventName, dataPartObject); } // Abort parsing of line there.