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: await scanner #11242

Merged
merged 4 commits into from Dec 7, 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
10 changes: 9 additions & 1 deletion packages/vite/src/node/optimizer/optimizer.ts
Expand Up @@ -161,10 +161,16 @@ async function createDepsOptimizer(
let firstRunCalled = !!cachedMetadata

let postScanOptimizationResult: Promise<DepOptimizationResult> | undefined
let discoverProjectDependenciesPromise:
| Promise<Record<string, string>>
| undefined

let optimizingNewDeps: Promise<DepOptimizationResult> | undefined
async function close() {
closed = true
await discoverProjectDependenciesPromise?.catch(() => {
/* ignore error for scanner because it's not important */
})
await postScanOptimizationResult
await optimizingNewDeps
}
Expand Down Expand Up @@ -202,7 +208,9 @@ async function createDepsOptimizer(
try {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should wrap this callback and await that instead of just awaiting this part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the whole promise handling here is due a refactoring. Lets merge this this change that works so we can release a patch

debug(colors.green(`scanning for dependencies...`))

const deps = await discoverProjectDependencies(config)
discoverProjectDependenciesPromise =
discoverProjectDependencies(config)
const deps = await discoverProjectDependenciesPromise

debug(
colors.green(
Expand Down
@@ -1,7 +1,7 @@
import { expect, test } from 'vitest'
import { getColor, page, untilUpdated } from '~utils'

test.skip('should have css applied on second dynamic import', async () => {
test('should have css applied on second dynamic import', async () => {
await untilUpdated(() => page.textContent('.content'), 'Initial', true)
await page.click('.b')

Expand Down