Skip to content

Commit 65014a3

Browse files
authored
fix(preview): set resolvedUrls null after close (#18445)
1 parent 8e382a6 commit 65014a3

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

docs/guide/api-javascript.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ interface ViteDevServer {
128128
*/
129129
moduleGraph: ModuleGraph
130130
/**
131-
* The resolved urls Vite prints on the CLI. null in middleware mode or
132-
* before `server.listen` is called.
131+
* The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
132+
* in middleware mode or if the server is not listening on any port.
133133
*/
134134
resolvedUrls: ResolvedServerUrls | null
135135
/**
@@ -274,8 +274,8 @@ interface PreviewServer {
274274
*/
275275
httpServer: http.Server
276276
/**
277-
* The resolved urls Vite prints on the CLI.
278-
* null before server is listening.
277+
* The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
278+
* if the server is not listening on any port.
279279
*/
280280
resolvedUrls: ResolvedServerUrls | null
281281
/**

packages/vite/src/node/preview.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ export interface PreviewServer {
8484
*/
8585
httpServer: HttpServer
8686
/**
87-
* The resolved urls Vite prints on the CLI.
88-
* null before server is listening.
87+
* The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
88+
* if the server is not listening on any port.
8989
*/
9090
resolvedUrls: ResolvedServerUrls | null
9191
/**
@@ -154,6 +154,7 @@ export async function preview(
154154
async close() {
155155
teardownSIGTERMListener(closeServerAndExit)
156156
await closeHttpServer()
157+
server.resolvedUrls = null
157158
},
158159
resolvedUrls: null,
159160
printUrls() {

packages/vite/src/node/server/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ export interface ViteDevServer {
284284
*/
285285
moduleGraph: ModuleGraph
286286
/**
287-
* The resolved urls Vite prints on the CLI. null in middleware mode or
288-
* before `server.listen` is called.
287+
* The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
288+
* in middleware mode or if the server is not listening on any port.
289289
*/
290290
resolvedUrls: ResolvedServerUrls | null
291291
/**

0 commit comments

Comments
 (0)