Heroku Foreman Exits on Express.js bodyParser() call

750 views Asked by At

When running foreman start, I see the following message

> foreman start
20:38:55 web.1  | started with pid 3896
20:38:55 web.1  | Development
20:38:56 web.1  | connect.multipart() will be removed in connect 3.0
20:38:56 web.1  | exited with code 1
20:38:56 system | sending SIGKILL to all processes

I was wondering why this was the case, since running node server.js does not appear to terminate the server.

Here is the segment of code that appears to cause the app to terminate with exit code 1:

var app = express();
app.configure(function()
{
    // More config things above
    app.use(express.bodyParser());   // This line is causing the issue
    // More config things below
}

The above is code using the Express.js framework. Removing the above call to express.bodyParser() allows the server to run (via foreman). The problem is, I'll need the body parser module in order to parse my incoming get/posts requests.

Any help on this issue would be much appreciated.

1

There are 1 answers

3
ivoszz On BEST ANSWER

I have no idea why foreman exits when deprecation warning is reported in express, but you can eliminate this behavior replacing app.use(express.bodyParser()); with

app.use(express.json());
app.use(express.urlencoded());

connect.multipart() will be removed from bodyParserin next version of Connect and this is probably the issue. You can find more info in Connect documenattion and/or in this StackOverflow Q&A.