Skip to content

fix: prevent infinite polling loop when deployment status is error#224

Open
codxbrexx wants to merge 1 commit intometacall:masterfrom
codxbrexx:fix/logs-polling-loops
Open

fix: prevent infinite polling loop when deployment status is error#224
codxbrexx wants to merge 1 commit intometacall:masterfrom
codxbrexx:fix/logs-polling-loops

Conversation

@codxbrexx
Copy link
Contributor

Fix Infinite Logs Polling Loop

Fixes: #223

Problem

CLI hangs indefinitely when deployment status reaches error or fail state because polling loop only checks for ready status.

Solution

  • Define terminal states: ['ready', 'error', 'fail']
  • Exit loop when any terminal state is reached
  • Add max attempt limit (360 attempts = 1 hour) as timeout safety net
  • Exit with code 1 and error message on failure states

Changes

  • src/logs.ts: Replace single status check with terminal states array
  • src/test/logs.spec.ts: Add 17 unit tests for polling behavior

Impact

  • Prevents CLI from hanging on failed deployments
  • Provides clear error feedback to users
  • Timeout protection against edge cases

Tests

image

… fail

- Replace single 'ready' status check with terminal states array: ['ready', 'error', 'fail']
- Change loop condition from 'status !== ready' to '!TERMINAL_STATES.includes(status)'
- Add MAX_POLL_ATTEMPTS protection (360 attempts = 1 hour at 10s intervals) as timeout safety net
- Exit with code 1 and appropriate error messages for 'error' and 'fail' states
- Increment poll attempts counter to track and limit polling iterations
- Previously, deployments reaching error state would cause infinite polling and CLI hang

Fixes: ISSUE metacall#223 - logs polling never ends on error status

Test Coverage:
- 17 unit tests covering terminal states, max attempts, polling behavior
- Tests for error recovery and log output handling
- All tests passing
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.

1 participant