MCPcopy
hub / github.com/webpack/webpack-dev-server / stop

Method stop

lib/Server.js:3634–3729  ·  view source on GitHub ↗

* @returns {Promise }

()

Source from the content-addressed store, hash-verified

3632 * @returns {Promise<void>}
3633 */
3634 async stop() {
3635 if (this.bonjour) {
3636 await /** @type {Promise<void>} */ (
3637 new Promise((resolve) => {
3638 this.stopBonjour(() => {
3639 resolve();
3640 });
3641 })
3642 );
3643 }
3644
3645 this.webSocketProxies = [];
3646
3647 await Promise.all(this.staticWatchers.map((watcher) => watcher.close()));
3648
3649 this.staticWatchers = [];
3650
3651 if (this.webSocketServer) {
3652 await /** @type {Promise<void>} */ (
3653 new Promise((resolve) => {
3654 /** @type {WebSocketServerImplementation} */
3655 (this.webSocketServer).implementation.close(() => {
3656 this.webSocketServer = null;
3657
3658 resolve();
3659 });
3660
3661 for (const client of /** @type {WebSocketServerImplementation} */ (
3662 this.webSocketServer
3663 ).clients) {
3664 client.terminate();
3665 }
3666
3667 /** @type {WebSocketServerImplementation} */
3668 (this.webSocketServer).clients = [];
3669 })
3670 );
3671 }
3672
3673 if (this.server) {
3674 await /** @type {Promise<void>} */ (
3675 new Promise((resolve) => {
3676 /** @type {S} */
3677 (this.server).close(() => {
3678 this.server = undefined;
3679 resolve();
3680 });
3681
3682 for (const socket of this.sockets) {
3683 socket.destroy();
3684 }
3685
3686 this.sockets = [];
3687
3688 // Force-close any remaining connections that aren't in `this.sockets`
3689 // (HTTP keep-alive idle connections from upstream clients,
3690 // long-poll requests, sockets that were upgraded out of `connection`
3691 // tracking, etc). Without this, `server.close()`'s callback can hang

Callers 15

stopCallbackMethod · 0.95
onShutdownMethod · 0.95
bundle.test.jsFile · 0.80
teardownFunction · 0.80
mime-types.test.jsFile · 0.80
target.test.jsFile · 0.80
entry.test.jsFile · 0.80

Calls 1

stopBonjourMethod · 0.95

Tested by 1

teardownFunction · 0.64