Skip to content

Commit a543220

Browse files
authored
fix: Remove ssrError when invalidating a module (#8124)
1 parent 50f8f3b commit a543220

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { beforeEach, describe, expect, it } from 'vitest'
2+
import { ModuleGraph } from '../moduleGraph'
3+
let moduleGraph: ModuleGraph
4+
5+
describe('moduleGraph', () => {
6+
describe('invalidateModule', () => {
7+
beforeEach(() => {
8+
moduleGraph = new ModuleGraph((id) => Promise.resolve({ id }))
9+
})
10+
11+
it('removes an ssrError', async () => {
12+
const entryUrl = '/x.js'
13+
14+
const entryModule = await moduleGraph.ensureEntryFromUrl(entryUrl, false)
15+
entryModule.ssrError = new Error(`unable to execute module`)
16+
17+
expect(entryModule.ssrError).to.be.a('error')
18+
moduleGraph.invalidateModule(entryModule)
19+
expect(entryModule.ssrError).toBe(null)
20+
})
21+
})
22+
})

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

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function invalidateSSRModule(mod: ModuleNode, seen: Set<ModuleNode>) {
5555
}
5656
seen.add(mod)
5757
mod.ssrModule = null
58+
mod.ssrError = null
5859
mod.importers.forEach((importer) => invalidateSSRModule(importer, seen))
5960
}
6061

0 commit comments

Comments
 (0)