Skip to content

Instantly share code, notes, and snippets.

Viper Bailey jinxidoru

Block or report user

Report or block jinxidoru

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jinxidoru / closeable_http_server.ts
Last active Feb 11, 2020
Closeable http server
View closeable_http_server.ts
import * as http from 'http'
import * as _ from 'lodash'
//! In the standard implementation of http server, calling close is not guaranteed to close the
//! server. Any idle connections being kept alive by clients will stay open until their timeout
//! is reached. This is problematic for gracefully shutting down a process with an http server.
//! This function will create an http server that tracks the open connections. On close, idle
//! connections are closed and any newly idled connection is immediately closed as well. When there
//! are no more connections on the server, the 'empty' event is raised.
You can’t perform that action at this time.