Skip to content
Open
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
21 changes: 18 additions & 3 deletions tests/integration/utils/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ const startServer = async ({
skipWaitPort = false,
targetPort,
}: DevServerOptions): Promise<DevServer | { timeout: boolean; output: string }> => {
const port = await getPort()
// Use worker-specific port ranges to avoid conflicts in parallel execution
const workerId = process.env.VITEST_WORKER_ID || '1'
const workerOffset = (parseInt(workerId) - 1) * 100
const port = await getPort({ port: getPort.makeRange(3000 + workerOffset, 3000 + workerOffset + 99) })
const host = 'localhost'
const url = `http://${host}:${port}`

Expand All @@ -89,7 +92,8 @@ const startServer = async ({
if (targetPort) {
baseArgs.push('--target-port', targetPort.toString())
} else {
const staticPort = await getPort()
// Use same worker-specific range for static port
const staticPort = await getPort({ port: getPort.makeRange(4000 + workerOffset, 4000 + workerOffset + 99) })
baseArgs.push('--staticServerPort', staticPort.toString())
}

Expand Down Expand Up @@ -158,7 +162,18 @@ const startServer = async ({
},
close: async () => {
selfKilled = true
await killProcess(ps)
// Enhanced cleanup for Windows to handle Next.js child processes
if (process.platform === 'win32' && ps.pid) {
try {
// Kill process tree on Windows to ensure all child processes are terminated
await execa('taskkill', ['/pid', ps.pid.toString(), '/T', '/F'])
} catch {
// Fallback to standard kill if taskkill fails
await killProcess(ps)
}
} else {
await killProcess(ps)
}
},
promptHistory,
})
Expand Down
6 changes: 0 additions & 6 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ export default defineConfig({
escapeString: true,
},
// Pin to vitest@1 behavior: https://vitest.dev/guide/migration.html#default-pool-is-forks.
// TODO(serhalp) Remove this and fix hanging `next-app-without-config` fixture on Windows.
pool: 'threads',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to also remove this? the new forks default is supposed to be so much more reliable!

Suggested change
pool: 'threads',

poolOptions: {
threads: {
singleThread: true,
},
},
coverage: {
provider: 'v8',
reporter: ['text', 'lcov'],
Expand Down
6 changes: 0 additions & 6 deletions vitest.e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ export default defineConfig({
include: ['e2e/**/*.e2e.[jt]s'],
testTimeout: 1200_000,
// Pin to vitest@1 behavior: https://vitest.dev/guide/migration.html#default-pool-is-forks.
// TODO(serhalp) Remove this and fix flaky hanging e2e tests on Windows.
pool: 'threads',
poolOptions: {
threads: {
singleThread: true,
},
},
},
})
Loading