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: extend logging of process timeout errors #3452

Merged
merged 1 commit into from May 30, 2023
Merged
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
27 changes: 21 additions & 6 deletions packages/vitest/src/node/core.ts
Expand Up @@ -700,14 +700,15 @@ export class Vitest {

async close() {
if (!this.closingPromise) {
const closePromises = this.projects.map(w => w.close())
const closePromises = this.projects.map(w => w.close().then(() => w.server = undefined as any))
// close the core workspace server only once
if (this.coreWorkspace && !this.projects.includes(this.coreWorkspace))
closePromises.push(this.server.close())
this.closingPromise = Promise.allSettled([
this.pool?.close(),
...closePromises,
].filter(Boolean)).then((results) => {
closePromises.push(this.server.close().then(() => this.server = undefined as any))

if (this.pool)
closePromises.push(this.pool.close().then(() => this.pool = undefined))

this.closingPromise = Promise.allSettled(closePromises).then((results) => {
results.filter(r => r.status === 'rejected').forEach((err) => {
this.logger.error('error during close', (err as PromiseRejectedResult).reason)
})
Expand All @@ -724,6 +725,20 @@ export class Vitest {
this.report('onProcessTimeout').then(() => {
console.warn(`close timed out after ${this.config.teardownTimeout}ms`)
this.state.getProcessTimeoutCauses().forEach(cause => console.warn(cause))

if (!this.pool) {
const runningServers = [this.server, ...this.projects.map(p => p.server)].filter(Boolean).length

if (runningServers === 1)
console.warn('Tests closed successfully but something prevents Vite server from exiting')
AriPerkkio marked this conversation as resolved.
Show resolved Hide resolved
else if (runningServers > 1)
console.warn(`Tests closed successfully but something prevents ${runningServers} Vite servers from exiting`)
else
console.warn('Tests closed successfully but something prevents the main process from exiting')

console.warn('You can try to identify the cause by enabling "hanging-process" reporter. See https://vitest.dev/config/#reporters')
}

process.exit()
})
}, this.config.teardownTimeout).unref()
Expand Down