Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove ssrError when invalidating a module #8124

Merged
merged 1 commit into from May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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