Files
cypress/packages/server/lib/util/server_destroy.ts
Lachlan Miller ab401ecd35 chore: use import type syntax (#17864)
* chore: use import type across repo

* chore: use import type across repo

* chore: use import type across repo

* chore: use import type across repo

* update exports

* update test

* update import type

* update types

* use import type in driver

* correctly export function

* revert test

* remove unrelated code

* revert code

* improve type imports

* override for reporter
2021-08-25 09:11:56 +10:00

22 lines
541 B
TypeScript

import Bluebird from 'bluebird'
import type 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
}