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

feat: make close timeout configurable #1697

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ Default timeout of a test in milliseconds

Default timeout of a hook in milliseconds

### teardownTimeout

- **Type:** `number`
- **Default:** `1000`

Default timeout to wait for close when Vitest shuts down, in milliseconds

### silent

- **Type:** `boolean`
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const config = {
exclude: defaultExclude,
testTimeout: 5000,
hookTimeout: 10000,
teardownTimeout: 1000,
isolate: true,
watchExclude: ['**/node_modules/**', '**/dist/**'],
forceRerunTriggers: [
Expand Down
5 changes: 2 additions & 3 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { Logger } from './logger'
import { VitestCache } from './cache'

const WATCHER_DEBOUNCE = 100
const CLOSE_TIMEOUT = 1_000

export class Vitest {
config: ResolvedConfig = undefined!
Expand Down Expand Up @@ -434,9 +433,9 @@ export class Vitest {

async exit(force = false) {
setTimeout(() => {
console.warn(`close timed out after ${CLOSE_TIMEOUT}ms`)
console.warn(`close timed out after ${this.config.teardownTimeout}ms`)
process.exit()
}, CLOSE_TIMEOUT).unref()
}, this.config.teardownTimeout).unref()

await this.close()
if (force)
Expand Down
7 changes: 7 additions & 0 deletions packages/vitest/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ export interface InlineConfig {
*/
hookTimeout?: number

/**
* Default timeout to wait for close when Vitest shuts down, in milliseconds
*
* @default 1000
*/
teardownTimeout?: number

/**
* Silent mode
*
Expand Down