Skip to content

Commit dc3e40e

Browse files
committed
chore: update debug
1 parent ebb321d commit dc3e40e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

packages/core/src/node/context.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { DevToolsViewHost } from './host-views'
1111
import { builtinRpcDecalrations } from './rpc'
1212

1313
const debugSetup = createDebug('vite:devtools:context:setup')
14-
const debugEvent = createDebug('vite:devtools:context:event')
1514

1615
export async function createDevToolsContext(
1716
viteConfig: ResolvedConfig,
@@ -47,14 +46,12 @@ export async function createDevToolsContext(
4746

4847
// Register hosts side effects
4948
docksHost.events.on('dock:entry:updated', debounce(() => {
50-
debugEvent('dock:entry:updated')
5149
rpcHost.broadcast({
5250
method: 'vite:internal:docks:updated',
5351
args: [],
5452
})
5553
}, 10))
5654
terminalsHost.events.on('terminal:session:updated', debounce(() => {
57-
debugEvent('terminal:session:updated')
5855
rpcHost.broadcast({
5956
method: 'vite:internal:terminals:updated',
6057
args: [],

packages/core/src/node/host-functions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import type { DevToolsNodeContext, DevToolsNodeRpcSession, DevToolsRpcClientFunc
22
import type { BirpcGroup } from 'birpc'
33
import type { AsyncLocalStorage } from 'node:async_hooks'
44
import { RpcFunctionsCollectorBase } from 'birpc-x'
5+
import { createDebug } from 'obug'
56
import { createRpcSharedStateServerHost } from './rpc-shared-state'
67

8+
const debugBroadcast = createDebug('vite:devtools:rpc:broadcast')
9+
710
export class RpcFunctionsHost extends RpcFunctionsCollectorBase<DevToolsRpcServerFunctions, DevToolsNodeContext> implements RpcFunctionsHostType {
811
/**
912
* @internal
@@ -28,6 +31,8 @@ export class RpcFunctionsHost extends RpcFunctionsCollectorBase<DevToolsRpcServe
2831
if (!this._rpcGroup)
2932
throw new Error('RpcFunctionsHost] RpcGroup is not set, it likely to be an internal bug of Vite DevTools')
3033

34+
debugBroadcast(JSON.stringify(options.method))
35+
3136
await Promise.all(
3237
this._rpcGroup.clients.map((client) => {
3338
if (options.filter?.(client) === false)

packages/core/src/node/ws.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import { createRpcServer } from '@vitejs/devtools-rpc'
88
import { createWsRpcPreset } from '@vitejs/devtools-rpc/presets/ws/server'
99
import c from 'ansis'
1010
import { getPort } from 'get-port-please'
11+
import { createDebug } from 'obug'
1112
import { MARK_INFO } from './constants'
1213
import { getInternalContext } from './context-internal'
1314

15+
const debugInvoked = createDebug('vite:devtools:rpc:invoked')
16+
1417
export interface CreateWsServerOptions {
1518
cwd: string
1619
portWebSocket?: number
@@ -92,6 +95,7 @@ export async function createWsServer(options: CreateWsServerOptions) {
9295

9396
// Register AsyncContext for the current RPC call
9497
return async function (this: any, ...args) {
98+
debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`)
9599
return await asyncStorage.run({
96100
rpc,
97101
meta: rpc.$meta,

0 commit comments

Comments
 (0)