mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-15 03:31:18 -06:00
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>
22 lines
536 B
TypeScript
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
|
|
}
|