Skip to content

Commit 946d8bb

Browse files
authored
fix(vitest): don't hang with maxConcurrency 0 (#6627)
1 parent 0d94e60 commit 946d8bb

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

packages/vitest/src/node/config/resolveConfig.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ export function resolveConfig(
207207
resolved.minWorkers = 1
208208
}
209209

210+
if (resolved.maxConcurrency === 0) {
211+
logger.console.warn(
212+
c.yellow(`The option "maxConcurrency" cannot be set to 0. Using default value ${configDefaults.maxConcurrency} instead.`),
213+
)
214+
resolved.maxConcurrency = configDefaults.maxConcurrency
215+
}
216+
210217
if (resolved.inspect || resolved.inspectBrk) {
211218
const isSingleThread
212219
= resolved.pool === 'threads'

test/config/test/failures.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,10 @@ test('mergeReports doesn\'t work with watch mode enabled', async () => {
279279

280280
expect(stderr).toMatch('Cannot merge reports with --watch enabled')
281281
})
282+
283+
test('maxConcurrency 0 prints a warning', async () => {
284+
const { stderr, ctx } = await runVitest({ maxConcurrency: 0 })
285+
286+
expect(ctx?.config.maxConcurrency).toBe(5)
287+
expect(stderr).toMatch('The option "maxConcurrency" cannot be set to 0. Using default value 5 instead.')
288+
})

test/config/vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default defineConfig({
1919
truncateThreshold: 999,
2020
},
2121
coverage: {
22+
// test that empty reporter does not throw
2223
reporter: [],
2324
},
2425
},

0 commit comments

Comments
 (0)