Please consider the simple express.js route:

```
app.get("/test", function(req, res) {
   if(condition1) {
      res.render("foo", {
          title : "Test"
      });
   }

   console.log("HERE");

   if(condition2) {
      res.render("bar", {
          title : "Test2"
      });
   }
});

```

Now, in this contrived example, sometimes condition1 will be true, and other times, condition2. However, in the case that condition1 is true, the control passes through and prints out the console.log line and then fails when it hits the other render with:

> 
> Error: Can't set headers after they are sent.
> 
> 
> 

It's like the response needs to be ended or something, but I've tried that, to no avail. Any help would be appreciated. Thanks.