creationix/step — Issue #23: Step is broken in Express.js!
Author: elii
Created: 2011-12-29 10:52:25+00:00
State: open

Hi,

I started to create an app with the most popular node web framework [Express.js](http://expressjs.com) and I discovered that Step might be broken if you want to use it inside of Express.

For me it seems that ```res.send()``` is causing Step to "step forward" which is a bad, bad thing. Look at the following example app:

```javascript
var express = require("express");
var step = require("step");

var app = express.createServer();

app.get("/", function(req, res)
{
step(
function one()
{
console.log("one");

if (true)
return res.send("one");

this();
},
function two()
{
console.log("two");

res.send("two");
}
);
});

app.listen(8080, function() {
console.log("App is running on port 8080");
});
```

If you run this example and go in your browser to ```http://localhost:8080``` this is what you get:

![](http://f.cl.ly/items/283I0s252W0H471E2U1U/Screen%20Shot%202011-12-29%20at%2011.46.42.png)

As you can see in the code, the output "two" actually never should be happen because the first function inside of step should always return.

IMHO this is a really crucial bug because it makes Step (which is awesome by the way) almost unusable for most node projects.