Skip to content

Commit 986d802

Browse files
committed
test: add e2e watch heartbeat
1 parent ea240c7 commit 986d802

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

e2e/watch/hot-update/shared.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ export function shouldRunGroupedTarget(caseName: WatchCaseName, target: WatchPro
404404

405405
async function runWatchHmrCommand(cwd: string, args: string[], commandTimeoutMs: number) {
406406
const maxAttempts = Math.max(1, toNumberEnv('E2E_WATCH_MAX_ATTEMPTS', 2))
407+
const heartbeatIntervalMs = Math.max(30_000, toNumberEnv('E2E_WATCH_HEARTBEAT_INTERVAL_MS', 60_000))
407408
const env = { ...process.env }
408409

409410
for (const key of Object.keys(env)) {
@@ -419,6 +420,12 @@ async function runWatchHmrCommand(cwd: string, args: string[], commandTimeoutMs:
419420
}
420421

421422
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
423+
const attemptStartedAt = Date.now()
424+
const heartbeat = setInterval(() => {
425+
const elapsedSeconds = Math.round((Date.now() - attemptStartedAt) / 1000)
426+
process.stdout.write(`[e2e-watch] watch-hmr attempt ${attempt}/${maxAttempts} still running (${elapsedSeconds}s elapsed)\n`)
427+
}, heartbeatIntervalMs)
428+
422429
try {
423430
await execa('pnpm', args, {
424431
cwd,
@@ -445,6 +452,9 @@ async function runWatchHmrCommand(cwd: string, args: string[], commandTimeoutMs:
445452
const message = error instanceof Error ? error.message : String(error)
446453
process.stdout.write(`[e2e-watch] watch-hmr attempt ${attempt} failed, retrying once: ${message}\n`)
447454
}
455+
finally {
456+
clearInterval(heartbeat)
457+
}
448458
}
449459
}
450460

0 commit comments

Comments
 (0)