Skip to content

Commit

Permalink
fix: Remove ssrError when invalidating a module (#8124)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed May 11, 2022
1 parent 50f8f3b commit a543220
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/vite/src/node/server/__tests__/moduleGraph.spec.ts
@@ -0,0 +1,22 @@
import { beforeEach, describe, expect, it } from 'vitest'
import { ModuleGraph } from '../moduleGraph'
let moduleGraph: ModuleGraph

describe('moduleGraph', () => {
describe('invalidateModule', () => {
beforeEach(() => {
moduleGraph = new ModuleGraph((id) => Promise.resolve({ id }))
})

it('removes an ssrError', async () => {
const entryUrl = '/x.js'

const entryModule = await moduleGraph.ensureEntryFromUrl(entryUrl, false)
entryModule.ssrError = new Error(`unable to execute module`)

expect(entryModule.ssrError).to.be.a('error')
moduleGraph.invalidateModule(entryModule)
expect(entryModule.ssrError).toBe(null)
})
})
})
1 change: 1 addition & 0 deletions packages/vite/src/node/server/moduleGraph.ts
Expand Up @@ -55,6 +55,7 @@ function invalidateSSRModule(mod: ModuleNode, seen: Set<ModuleNode>) {
}
seen.add(mod)
mod.ssrModule = null
mod.ssrError = null
mod.importers.forEach((importer) => invalidateSSRModule(importer, seen))
}

Expand Down

0 comments on commit a543220

Please sign in to comment.