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(vitest): don't hang with maxConcurrency 0 #6627

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/vitest/src/node/config/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ export function resolveConfig(
resolved.minWorkers = 1
}

if (resolved.maxConcurrency === 0) {
logger.console.warn(
c.yellow(`The option "maxConcurrency" cannot be set to 0. Using default value ${configDefaults.maxConcurrency} instead.`),
)
resolved.maxConcurrency = configDefaults.maxConcurrency
}

if (resolved.inspect || resolved.inspectBrk) {
const isSingleThread
= resolved.pool === 'threads'
Expand Down
7 changes: 7 additions & 0 deletions test/config/test/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,10 @@ test('mergeReports doesn\'t work with watch mode enabled', async () => {

expect(stderr).toMatch('Cannot merge reports with --watch enabled')
})

test('maxConcurrency 0 prints a warning', async () => {
const { stderr, ctx } = await runVitest({ maxConcurrency: 0 })

expect(ctx?.config.maxConcurrency).toBe(5)
expect(stderr).toMatch('The option "maxConcurrency" cannot be set to 0. Using default value 5 instead.')
})
1 change: 1 addition & 0 deletions test/config/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default defineConfig({
truncateThreshold: 999,
},
coverage: {
// test that empty reporter does not throw
reporter: [],
},
},
Expand Down