{"shas":[["b1bc8a03d39deccd4081b3b94b575f924131a6c3","042dc4512fa3d391c5170cf3aa61e6a638f84342@ztrix.me","I think I've found a bug in step, which may cause code executing order to be changed. \r\n\r\nThis happens when check function in next.parallel executed before the Step sequence finished.\r\n\r\nHere is an small example illustrating this:\r\n\r\n== code begin\r\n\r\nfunction C(param, callback) {\r\n    Step(\r\n        function D(){\r\n            do_some_IO(param, this);\r\n        },\r\n\r\n        function E(err, some_data){\r\n            this(undefined, some_data);\r\n        },\r\n\r\n        callback\r\n    );\r\n}\r\n\r\n\r\nStep(\r\n    function A(err) {\r\n        IO1(data, this.parallel();\r\n        IO2(data, this.parallel());\r\n    },\r\n\r\n    function B(err, data1, data2) {\r\n        C(data, this);\r\n    },\r\n\r\n    function F(err, data) {\r\n        // finish\r\n    }\r\n);\r\n\r\n== code end\r\n\r\n\r\n we write this code expecting the code running in this order, A->B->C->D->E->F, \r\n but in fact, the order may be changed to A->B->C->D->F->E\r\n\r\nwhen A is executing, this.parallel() will set 2 process.nextTick in step,\r\nthen, when D is performing IO, process.nextTick begins as the the next event loop, and F is shifted from the queue and executed as the next fn in step(function next), thus F will be executed before E, causing the whole program in error.\r\n\r\nSo I suggest that we could add a variable telling whether `check` has been executed by callback, and avoid executing check if `check` has been invoked by callback. By the way, I think function `next.group` is suffering from the same bug, but I did not write code to prove it.\r\n\r\nI encountered this problem when modifying code of `wheat`. Thanks a lot for writing such great code.\r\n\r\nregards,\r\nzTrix\r","Wenlei Zhu"]],"ref":"refs/heads/patch-1","size":1,"head":"b1bc8a03d39deccd4081b3b94b575f924131a6c3","push_id":37424198}