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

Fix HTTP 502s from AWS ALB #533

Merged
merged 4 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions api/function-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import debug from 'debug';
process.env.DEBUG = process.env.DEBUG || 'fusebit';

import Debug from 'debug';
import http from 'http';
import app from './app';

debug('flexd-functions:server');
const debug = Debug('fusebit');
debug('Starting');

process.on('uncaughtException', (e: Error) => {
debug('UNCAUGHT ERROR:', e.stack || e);
setTimeout(() => process.exit(1), 100);
});

const normalizedPort = normalizePort(process.env.PORT || 3001);
app.set('port', normalizedPort);

const server = http.createServer(app);
server.listen(normalizedPort);
// Work-around for the Node 10.15.3 issue
// See https://shuheikagawa.com/blog/2019/04/25/keep-alive-timeout/
// See https://github.com/nodejs/node/issues/27363
// ALB timeout is 120s
server.keepAliveTimeout = 130 * 1000;
server.headersTimeout = 150 * 1000;

server.listen(normalizedPort);
server.on('error', onError);
server.on('listening', onListening);

Expand Down Expand Up @@ -39,11 +53,11 @@ function onError(error: any) {
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
debug(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
debug(bind + ' is already in use');
process.exit(1);
break;
default:
Expand Down
6 changes: 6 additions & 0 deletions docs/fusebit-http-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ All public releases of the Fusebit HTTP API are documented here, including notab
<!-- 1. TOC
{:toc} -->

## Version 1.14.2

_Released 1/22/20_

- **Bug fix** Mitigation for a race condition in keep-alive timing between AWS ALB and Fusebit server that resulted in sporadic HTTP 502 responses.

## Version 1.14.1

_Released 1/13/20_
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.14.1",
"version": "1.14.2",
"private": true,
"org": "5qtrs",
"scripts": {
Expand Down