Skip to content

Commit

Permalink
revert: close pool early in run-mode #4623
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 9, 2023
1 parent e4f3d0a commit 7e5594d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ViteNodeRunner } from 'vite-node/client'
import { SnapshotManager } from '@vitest/snapshot/manager'
import type { CancelReason, File } from '@vitest/runner'
import { ViteNodeServer } from 'vite-node/server'
import type { ArgumentsType, Awaitable, CoverageProvider, OnServerRestartHandler, Reporter, ResolvedConfig, UserConfig, UserWorkspaceConfig, VitestRunMode } from '../types'
import type { ArgumentsType, CoverageProvider, OnServerRestartHandler, Reporter, ResolvedConfig, UserConfig, UserWorkspaceConfig, VitestRunMode } from '../types'
import { hasFailed, noop, slash, toArray } from '../utils'
import { getCoverageProvider } from '../integrations/coverage'
import type { BrowserProvider } from '../types/browser'
Expand Down Expand Up @@ -76,7 +76,6 @@ export class Vitest {
private _onClose: (() => Awaited<unknown>)[] = []
private _onSetServer: OnServerRestartHandler[] = []
private _onCancelListeners: ((reason: CancelReason) => Promise<void> | void)[] = []
private _poolClosePromise?: Awaitable<void>

async setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig) {
this.unregisterWatcher?.()
Expand Down Expand Up @@ -358,10 +357,6 @@ export class Vitest {
await this.runFiles(files)
}

// In run mode close pool as early as possible
if (!this.config.watch && this.pool?.close)
this._poolClosePromise = this.pool.close()

await this.reportCoverage(true)

if (this.config.watch)
Expand Down Expand Up @@ -785,9 +780,8 @@ export class Vitest {

if (this.pool) {
closePromises.push((async () => {
await (this._poolClosePromise || this.pool?.close?.())
await this.pool?.close?.()

this._poolClosePromise = undefined
this.pool = undefined
})())
}
Expand Down

0 comments on commit 7e5594d

Please sign in to comment.