Skip to content

Commit 12bf5a3

Browse files
webfansplzantfu
andauthored
perf(vite): use disk logs with in-memory metadata (#400)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 5a35924 commit 12bf5a3

24 files changed

Lines changed: 3530 additions & 361 deletions

docs/errors/VDT0003.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# VDT0003: Inspect Storage Error
6+
7+
## Message
8+
9+
> Vite inspect storage failed while `{operation}`.
10+
11+
## Cause
12+
13+
The Vite inspect collector encountered a payload or plugin-call archive initialization, batched write, read, or shutdown failure.
14+
15+
## Example
16+
17+
Starting the Vite DevTools Vite UI plugin with an unwritable Vite cache directory can trigger this error.
18+
19+
## Fix
20+
21+
Restart the Vite dev server. If the error persists, clear the Vite cache directory and reinstall dependencies.
22+
23+
## Source
24+
25+
- [`packages/vite/src/node/inspect/store/index.ts`](https://github.com/vitejs/devtools/blob/main/packages/vite/src/node/inspect/store/index.ts) — the inspect store emits this when archive setup, batched writes, reads, or shutdown fail.
26+
- [`packages/vite/src/node/inspect/store/payload.ts`](https://github.com/vitejs/devtools/blob/main/packages/vite/src/node/inspect/store/payload.ts) — the payload archive emits this when an in-memory or file-backed payload cannot be read or written completely.
27+
- [`packages/vite/src/node/inspect/store/plugin-calls.ts`](https://github.com/vitejs/devtools/blob/main/packages/vite/src/node/inspect/store/plugin-calls.ts) — the plugin-call archive emits this when a binary event cannot be encoded, read, or written completely.

docs/errors/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ Emitted by `@vitejs/devtools-vite`.
5151
|------|-------|-------|
5252
| [VDT0001](./VDT0001) | error | Inspect Context Unavailable |
5353
| [VDT0002](./VDT0002) | error | Inspect Target Not Found |
54+
| [VDT0003](./VDT0003) | error | Inspect Storage Error |

packages/core/playground/vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { hideDockWhenEmpty } from '../../core/src/node/plugins/auto-hide'
1717
// eslint-disable-next-line ts/ban-ts-comment
1818
// @ts-ignore ignore the type error
1919
import { DevToolsRolldownUI } from '../../rolldown/src/node'
20+
import { DevToolsViteUI } from '../../vite/src/node'
2021

2122
declare module '@vitejs/devtools-kit' {
2223
interface DevToolsRpcSharedStates {
@@ -74,6 +75,7 @@ export default defineConfig({
7475
builtinDevTools: false,
7576
}),
7677
DevToolsRolldownUI(),
78+
DevToolsViteUI(),
7779
UnoCSS(),
7880
Tracer({
7981
viteDevtools: true,

packages/vite/src/app/components/data/PluginDetailsLoader.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ const parsedPaths = computed(() => props.modules.map((mod) => {
9191
}))
9292
const moduleTypes = computed(() => ModuleTypeRules.filter(rule => parsedPaths.value.some(mod => rule.match.test(mod.mod.id))))
9393
94+
function getModuleGraphLink(moduleId: string | undefined): string | false {
95+
return moduleId
96+
? `/graph?module=${encodeURIComponent(moduleId)}`
97+
: false
98+
}
99+
94100
const _tree = computed(() => {
95101
const map = new Map<string, TreeNodeInput<PluginChartInfo | undefined>>()
96102
const maxDepth = 3
@@ -338,7 +344,7 @@ watch(() => settings.value.pluginDetailsViewType, () => {
338344
:id="child.text!"
339345
w-full border-none ws-nowrap
340346
:cwd="root"
341-
:link="`/graph?module=${encodeURIComponent(child.text!)}`"
347+
:link="getModuleGraphLink(child.meta?.graphModuleId)"
342348
hover="bg-active"
343349
border="~ base rounded" block px2 py1
344350
/>

packages/vite/src/app/components/data/PluginDetailsTable.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const moduleTypeNameMap = computed(() => {
4141
4242
return map
4343
})
44-
4544
const filterModuleTypes = ref<string[]>(settings.value.pluginDetailsModuleTypes ?? searchFilterTypes.value.map(item => item.name))
4645
const selectedModuleTypes = computed(() => new Set(filterModuleTypes.value))
4746
const { state: durationSortType, next } = useCycleList(['', 'desc', 'asc'], {
@@ -97,6 +96,12 @@ function toggleDurationSortType() {
9796
next()
9897
settings.value.pluginDetailsDurationSortType = durationSortType.value
9998
}
99+
100+
function getModuleGraphLink(moduleId: string | undefined): string | false {
101+
return moduleId
102+
? `/graph?module=${encodeURIComponent(moduleId)}`
103+
: false
104+
}
100105
</script>
101106

102107
<template>
@@ -181,7 +186,7 @@ function toggleDurationSortType() {
181186
:id="item.module"
182187
w-full border-none ws-nowrap
183188
:cwd="root"
184-
:link="`/graph?module=${encodeURIComponent(item.module)}`"
189+
:link="getModuleGraphLink(item.graphModuleId)"
185190
hover="bg-active"
186191
border="~ base rounded" block px2 py1
187192
/>

0 commit comments

Comments
 (0)