Skip to content

Conversation

@phuongnd08
Copy link
Collaborator

Summary

Fixed a critical issue where Playwright E2E tests would complete successfully but the worker would timeout during teardown after 60 seconds. This was caused by floating promises in the scheduler's recursive chain.

Problem

The latest commit on main (7b1e53b6) broke the CI build with a worker teardown timeout:

  • All 45 E2E tests pass successfully
  • Last test completes at 09:00:35
  • Worker teardown timeout occurs at 09:01:35 (exactly 60 seconds later)
  • Error: Worker teardown timeout of 60000ms exceeded

Root Cause

In ClaudeTerminal.tsx, the scheduleNext() function had two issues:

  1. Line 211: Called scheduleNext() recursively without returning the promise
  2. Line 219: Called scheduleNext() without any promise handling

This created untracked promise chains that continued running even after tests completed, preventing the Playwright worker from cleaning up properly.

Solution

  1. Added explicit Promise<void> return type to scheduleNext function for clarity
  2. Changed line 213 to return scheduleNext() to properly chain the recursive promise
  3. Used void operator on line 221 to explicitly mark the initial call as fire-and-forget while maintaining the promise chain internally

This ensures that when stopScheduler() is called (either explicitly or during test cleanup), the entire promise chain can resolve properly, allowing the Playwright worker to teardown without timing out.

Changes

  • apps/desktop/src/renderer/components/ClaudeTerminal.tsx: Fixed promise handling in scheduler

Test Plan

  • Local lint and type check passes
  • CI E2E tests complete without worker teardown timeout
  • Verify fix by running CI build 3 times consecutively

Evidence

CI logs from failed build (19359320911):

2025-11-14T09:00:35.9366332Z   ✓  45 [electron] › e2e/worktree-terminal-content-preservation.spec.ts:82:7
2025-11-14T09:01:35.9412859Z [31mWorker teardown timeout of 60000ms exceeded.[39m

🤖 Generated with Claude Code

phuongnd08 and others added 8 commits November 14, 2025 16:43
…cheduler promises

Fixed a critical issue where Playwright E2E tests would complete successfully
but the worker would timeout during teardown after 60 seconds. This was caused
by floating promises in the scheduler's recursive chain.

Problem:
- The scheduleNext() function in ClaudeTerminal.tsx was calling itself recursively
  on line 211 without returning the promise
- Line 219 was calling scheduleNext() without any promise handling
- This created untracked promise chains that continued running even after tests
  completed, preventing the Playwright worker from cleaning up properly
- All 45 tests would pass, but the worker teardown would timeout at exactly 60s

Solution:
- Added explicit Promise<void> return type to scheduleNext function
- Changed line 213 to 'return scheduleNext()' to properly chain the promise
- Used 'void' operator on line 221 to explicitly mark the initial call as
  fire-and-forget while maintaining the promise chain internally
- This allows the promise chain to be properly tracked and cleaned up when
  the scheduler is stopped

The fix ensures that when stopScheduler() is called (either explicitly or during
test cleanup), the entire promise chain can resolve properly, allowing the
Playwright worker to teardown without timing out.

Evidence from CI logs:
- Last test completed: 09:00:35
- Worker timeout: 09:01:35 (exactly 60s later)
- Error: "Worker teardown timeout of 60000ms exceeded"

This fixes the broken main build at commit 7b1e53b.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants