Skip to content

Commit 1949d58

Browse files
committed
fix: lets see if we improve nextjs windows issue
1 parent d1fd106 commit 1949d58

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

tests/integration/utils/dev-server.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ const startServer = async ({
7171
skipWaitPort = false,
7272
targetPort,
7373
}: DevServerOptions): Promise<DevServer | { timeout: boolean; output: string }> => {
74-
const port = await getPort()
74+
// Use worker-specific port ranges to avoid conflicts in parallel execution
75+
const workerId = process.env.VITEST_WORKER_ID || '1'
76+
const workerOffset = (parseInt(workerId) - 1) * 100
77+
const port = await getPort({ port: getPort.makeRange(3000 + workerOffset, 3000 + workerOffset + 99) })
7578
const host = 'localhost'
7679
const url = `http://${host}:${port}`
7780

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

@@ -158,7 +162,18 @@ const startServer = async ({
158162
},
159163
close: async () => {
160164
selfKilled = true
161-
await killProcess(ps)
165+
// Enhanced cleanup for Windows to handle Next.js child processes
166+
if (process.platform === 'win32' && ps.pid) {
167+
try {
168+
// Kill process tree on Windows to ensure all child processes are terminated
169+
await execa('taskkill', ['/pid', ps.pid.toString(), '/T', '/F'])
170+
} catch (error) {
171+
// Fallback to standard kill if taskkill fails
172+
await killProcess(ps)
173+
}
174+
} else {
175+
await killProcess(ps)
176+
}
162177
},
163178
promptHistory,
164179
})

vitest.config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ export default defineConfig({
1818
escapeString: true,
1919
},
2020
// Pin to vitest@1 behavior: https://vitest.dev/guide/migration.html#default-pool-is-forks.
21-
// TODO(serhalp) Remove this and fix hanging `next-app-without-config` fixture on Windows.
2221
pool: 'threads',
23-
poolOptions: {
24-
threads: {
25-
singleThread: process.platform === 'win32',
26-
},
27-
},
2822
coverage: {
2923
provider: 'v8',
3024
reporter: ['text', 'lcov'],

vitest.e2e.config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ export default defineConfig({
55
include: ['e2e/**/*.e2e.[jt]s'],
66
testTimeout: 1200_000,
77
// Pin to vitest@1 behavior: https://vitest.dev/guide/migration.html#default-pool-is-forks.
8-
// TODO(serhalp) Remove this and fix flaky hanging e2e tests on Windows.
98
pool: 'threads',
10-
poolOptions: {
11-
threads: {
12-
singleThread: true,
13-
},
14-
},
159
},
1610
})

0 commit comments

Comments
 (0)