Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird issue when running with latest express #13

Open
andrewmunro opened this issue Jan 28, 2016 · 2 comments
Open

Weird issue when running with latest express #13

andrewmunro opened this issue Jan 28, 2016 · 2 comments

Comments

@andrewmunro
Copy link

I have my piping code setup as such:

#!/usr/bin/env node
if (process.env.NODE_ENV !== 'production') {
    if (!require('piping')({
            hook: true,
            ignore: /(\/\.|~$|\.json$)/i
        })) {
        return;
    }
}

var express = require('express');
var http = require('http');

var app = express();
app.server = http.createServer(app);

app.server.listen(process.env.PORT || 8080);

console.log('Started on port' + app.server.address().port);

For some odd reason, when running this simple app with piping, app.server.address() returns null.
If I run this code without piping, it returns the port as expected.

Using "express": "^4.13.4" and "piping": "^0.3.0",

Any ideas?

@mntnoe
Copy link

mntnoe commented Feb 6, 2016

Hmm, it seems to be an issue with creating http servers on workers in general. The server still runs, though:

var cluster = require("cluster");

if (cluster.isMaster) {
  cluster.fork();
}
else {
  var http = require('http');
  var server = http.createServer(function(req, res) { res.end('ok'); });
  server.listen(process.env.PORT || 8080);
  console.log('Server address: ' + server.address());
}

I have been unable to find an explaination of this behavior, though.

@d-oliveros
Copy link

I'm having the same issue. I had to replace piping with nodemon for tests to work (using mocha). This issue was not apparent until I tried testing an express server with supertest, as supertest makes heavy use of app.server.address().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants