visionmedia/express — Issue #946: Step doesn't work with Express
Author: elii
Created: 2011-12-29 14:25:20+00:00
State: open

Hi,

I started to create an app with Express.js and I discovered that Step might be broken if you want to use it inside of Express.

Example:

```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.

It seems to me if Express is calling ```this()```somehow when calling ```res.send()```