From ba821bb63eca6d8a9199ee2253ef2607375f5702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 25 Nov 2024 22:42:42 +0900 Subject: [PATCH] fix: log error when send in module runner failed (#18753) --- packages/vite/src/shared/hmr.ts | 4 +++- packages/vite/src/shared/moduleRunnerTransport.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/shared/hmr.ts b/packages/vite/src/shared/hmr.ts index 76c4ece4d44919..342e0894bef971 100644 --- a/packages/vite/src/shared/hmr.ts +++ b/packages/vite/src/shared/hmr.ts @@ -190,7 +190,9 @@ export class HMRClient { } public send(payload: HotPayload): void { - this.transport.send(payload) + this.transport.send(payload).catch((err) => { + this.logger.error(err) + }) } public clear(): void { diff --git a/packages/vite/src/shared/moduleRunnerTransport.ts b/packages/vite/src/shared/moduleRunnerTransport.ts index f10ef69ba193bf..8fad9b0d2f5fe0 100644 --- a/packages/vite/src/shared/moduleRunnerTransport.ts +++ b/packages/vite/src/shared/moduleRunnerTransport.ts @@ -179,7 +179,7 @@ const createInvokeableTransport = ( export interface NormalizedModuleRunnerTransport { connect?(onMessage?: (data: HotPayload) => void): Promise | void disconnect?(): Promise | void - send(data: HotPayload): void + send(data: HotPayload): Promise invoke( name: T, data: Parameters,