Skip to content

Commit

Permalink
fix(hmr): hmr websocket failure for custom middleware mode with serve…
Browse files Browse the repository at this point in the history
…r.hmr.server (#11487)
  • Loading branch information
naruaway authored Jan 18, 2023
1 parent b1a8e58 commit 00919bb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/node/plugins/clientInjections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {
const protocol = hmrConfig?.protocol || null
const timeout = hmrConfig?.timeout || 30000
const overlay = hmrConfig?.overlay !== false
const isHmrServerSpecified = !!hmrConfig?.server

// hmr.clientPort -> hmr.port
// -> (24678 if middleware mode) -> new URL(import.meta.url).port
// -> (24678 if middleware mode and HMR server is not specified) -> new URL(import.meta.url).port
let port = hmrConfig?.clientPort || hmrConfig?.port || null
if (config.server.middlewareMode) {
if (config.server.middlewareMode && !isHmrServerSpecified) {
port ||= 24678
}

Expand Down

0 comments on commit 00919bb

Please sign in to comment.