Skip to content

Commit

Permalink
Be more strict on unhandled promise rejections (kriasoft#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
langpavel authored Feb 8, 2018
1 parent 6a00482 commit 9081d93
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ import schema from './data/schema';
import assets from './assets.json'; // eslint-disable-line import/no-unresolved
import config from './config';

const app = express();

//
// If you are using proxy from external machine, you can set TRUST_PROXY env
// Default is to trust proxy headers only from loopback interface.
// -----------------------------------------------------------------------------
app.set('trust proxy', config.trustProxy);
process.on('unhandledRejection', (reason, p) => {
console.error('Unhandled Rejection at:', p, 'reason:', reason);
// send entire app down. Process manager will restart it
process.exit(1);
});

//
// Tell any CSS tooling (such as Material UI) to use all vendor prefixes if the
Expand All @@ -46,6 +44,14 @@ app.set('trust proxy', config.trustProxy);
global.navigator = global.navigator || {};
global.navigator.userAgent = global.navigator.userAgent || 'all';

const app = express();

//
// If you are using proxy from external machine, you can set TRUST_PROXY env
// Default is to trust proxy headers only from loopback interface.
// -----------------------------------------------------------------------------
app.set('trust proxy', config.trustProxy);

//
// Register Node.js middleware
// -----------------------------------------------------------------------------
Expand Down

0 comments on commit 9081d93

Please sign in to comment.