Files
cypress/packages/server/lib/util/server_destroy.ts
Brian Mann af26fbebe6 feat: component testing (#14479)
Co-authored-by: Jessica Sachs <jess@jessicasachs.io>
Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Co-authored-by: ElevateBart <ledouxb@gmail.com>
Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
2021-02-04 15:45:16 -05:00

22 lines
536 B
TypeScript

import Bluebird from 'bluebird'
import http from 'http'
import * as network from '@packages/network'
export interface DestroyableHttpServer extends http.Server {
/** asynchronously destroys the http server, waiting
* for all open socket connections to first close
*/
destroyAsync (): Bluebird<void>
}
export const allowDestroy = (server) => {
network.allowDestroy(server)
server.destroyAsync = () => {
return Bluebird.promisify(server.destroy)()
.catch(() => {}) // dont catch any errors
}
return server
}