From 2b704df2a415dd7e46684017c79ddea35e258219 Mon Sep 17 00:00:00 2001 From: bluwy Date: Thu, 15 Feb 2024 22:40:47 +0800 Subject: [PATCH 1/2] Remove server-destroy dependency --- .changeset/poor-llamas-chew.md | 5 +++++ packages/astro/package.json | 2 -- packages/astro/src/core/preview/static-preview-server.ts | 9 +-------- 3 files changed, 6 insertions(+), 10 deletions(-) create mode 100644 .changeset/poor-llamas-chew.md diff --git a/.changeset/poor-llamas-chew.md b/.changeset/poor-llamas-chew.md new file mode 100644 index 000000000000..695b78f0d4a6 --- /dev/null +++ b/.changeset/poor-llamas-chew.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Simplifies internal Vite preview server teardown diff --git a/packages/astro/package.json b/packages/astro/package.json index 79bce5ef7ca7..6fe67b2e092d 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -166,7 +166,6 @@ "rehype": "^13.0.1", "resolve": "^1.22.4", "semver": "^7.5.4", - "server-destroy": "^1.0.1", "shikiji": "^0.9.19", "shikiji-core": "^0.9.19", "string-width": "^7.0.0", @@ -210,7 +209,6 @@ "@types/resolve": "^1.20.5", "@types/semver": "^7.5.2", "@types/send": "^0.17.4", - "@types/server-destroy": "^1.0.3", "@types/unist": "^3.0.2", "@types/yargs-parser": "^21.0.3", "astro-scripts": "workspace:*", diff --git a/packages/astro/src/core/preview/static-preview-server.ts b/packages/astro/src/core/preview/static-preview-server.ts index ba692611e939..5eb28d450886 100644 --- a/packages/astro/src/core/preview/static-preview-server.ts +++ b/packages/astro/src/core/preview/static-preview-server.ts @@ -1,7 +1,6 @@ import type http from 'node:http'; import { fileURLToPath } from 'node:url'; import { performance } from 'perf_hooks'; -import enableDestroy from 'server-destroy'; import { preview, type PreviewServer as VitePreviewServer } from 'vite'; import type { AstroSettings } from '../../@types/astro.js'; import type { Logger } from '../logger/core.js'; @@ -47,8 +46,6 @@ export default async function createStaticPreviewServer( throw err; } - enableDestroy(previewServer.httpServer); - // Log server start URLs logger.info( 'SKIP_FORMAT', @@ -73,10 +70,6 @@ export default async function createStaticPreviewServer( port: settings.config.server.port, closed, server: previewServer.httpServer as http.Server, - stop: async () => { - await new Promise((resolve, reject) => { - previewServer.httpServer.destroy((err) => (err ? reject(err) : resolve(undefined))); - }); - }, + stop: previewServer.close.bind(previewServer), }; } From d1de72ba43d4e8cf41896e886820d92a3d91e00d Mon Sep 17 00:00:00 2001 From: bluwy Date: Thu, 15 Feb 2024 22:44:16 +0800 Subject: [PATCH 2/2] Update lockfile --- pnpm-lock.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 835fe2ee97ba..b264f122d93a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -650,9 +650,6 @@ importers: semver: specifier: ^7.5.4 version: 7.5.4 - server-destroy: - specifier: ^1.0.1 - version: 1.0.1 shikiji: specifier: ^0.9.19 version: 0.9.19 @@ -772,9 +769,6 @@ importers: '@types/send': specifier: ^0.17.4 version: 0.17.4 - '@types/server-destroy': - specifier: ^1.0.3 - version: 1.0.3 '@types/unist': specifier: ^3.0.2 version: 3.0.2